c - How to iterate over a char pointer array -
how iterate on files variable in efficient way ?
should add null last value, or else ?
char *files[] = { "c1.txt", "r1.txt", "t2.c", "d.cpp", };
there several possibilities.
- you can add
null
final entry, suggest yourself - if array comes source (like file on disk), keep counter of number of lines you're reading
- but if array given in source, length constant , can check how many elements has (by subtracting line numbers)
- also, size of constant array
sizeof(files) / sizeof(char*)
.
Comments
Post a Comment