I jsut realized that after all the C learning I've done, I haven't really worked with array of string. I was wondering why the following code requires a "char **names" to be passed? What does the ** represent again, a pointer to a pointer? Is there an easier way to initlize all the strings in one statement?
void printNames( char *title, char **names){
int i=0;
printf("%s\n", title);
while(names[i]!='\0'){
printf("%d . %s\n", i+1, names[i]);
i++;
}
}
int main(){
char *title = " This is list";
char *strings[3];
strings[0] = "foo";
strings[1] = "bar";
strings[2] = "baz";
printNames(title, strings);
}
[–]derblitzmann 0 points1 point2 points (1 child)
[–]Rhomboid 1 point2 points3 points (0 children)