I want to find the length of this :
char *s[]={"s","a","b"};
it should count 4 with the /0 but the strlen or sizeof(s)/sizeof(char) gives me wrong answers.. How can i find it?
You are making an array of char*
and not of char
. That's why strlen
won't work. Use
sizeof(s) / sizeof(char*) //should give 3
If you want a single string use
char s[] = "sab";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With