- Using sizeof:
int a[17];
size_t n = sizeof(a) / sizeof(a[0]);
- Using a Macro function
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
Code snippets getted from Stack Overflow from ansewer of Mark Harrison
int a[17];
size_t n = sizeof(a) / sizeof(a[0]);
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
Code snippets getted from Stack Overflow from ansewer of Mark Harrison