Go Down

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

tuxduino

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] = {
    "COM1",
    "COM2",
};

char cmdArray2[][CMD_MAX_LEN] = {
    "COM1",
    "COM2"
};

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));
}


Result:
Code: [Select]

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

S_Flex


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!

Arduino
via Egeo 16
Torino, 10131
Italy