I'm trying to create "String Array Count" function. How does it it work? The loop is going to stop if the char is empty, then the length is going to show. The error is, empty char conditional didn't detect empty char. The result is infinite while loop.
Edit : I want the result of my function is 3
#include <stdio.h>
#define s 1000
int strarrlen(char str[s][s]){
int i, len = 0;
while (1){
if(str && !str[i]){
break;
} else {
len += 1;
}
i++;
}
return len;
}
int main(){
char words[s][s] = {"First", "Second", "Third"};
printf("words array total is %i", strarrlen(words));
}