I've a string array:
char array[128][128];
To add strings in this array, I read a file, and append a line if "192.168.101.2" is contained in that line:
while ((read = getline(&line, &len, fp)) != -1) {
if (strstr(line, "192.168.101.2") != NULL) {
printf("%s\n", line);
strcpy(array[i], line);
i++;
}
}
Now, I would like to know how many strings this array contains. I've tried:
sizeof(array)/sizeof(array[0]), but it always returns 128. How can I achieve this?
And, how can i pass an array of strings to a function? I've tried:
void array_length(char array[int][int]);
but:
main.c:15:31: error: expected expression before ‘int’
15 | void array_length(char array [int][int]);