Go Down

Topic: PWM - Fade a pin (Read 3399 times) previous topic - next topic


I don't have an arduino at hand, so I tested this on linux:

Code: [Select]

#define ARY_LEN(a) (sizeof(a)/sizeof(a[0]))

#define CMD_MAX_LEN 50

char cmdArray1[][CMD_MAX_LEN] = {

char cmdArray2[][CMD_MAX_LEN] = {

void main(int argc, char** argv) {
    printf("ary len 1 = %d\n", ARY_LEN(cmdArray1));
    printf("ary len 2 = %d\n", ARY_LEN(cmdArray2));

    printf("sizeof(ary1) = %d\n", sizeof(cmdArray1));
    printf("sizeof(ary2) = %d\n", sizeof(cmdArray2));

Code: [Select]

ary len 1 = 2
ary len 2 = 2
sizeof(ary1) = 100
sizeof(ary2) = 100


Using ARY_LEN(commands) is IMHO more convenient than having to update a constant every time you add or remove a string from the array.

I agree!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131