running UNIX through putty, and using vi and gcc. I am attempting to read in a line of a file and using a ragged array store the lines. I won't provide the whole code because it is unnecessary,
main(){
char func[51];
char * functions[201];
FILE * inf;
if (( inf = fopen("test.txt", "r")) == NULL){
printf("can't open so exiting\n");
exit(EXIT_SUCCESS)
int i;
i = 0;
while( fscanf(inf, "%s", func) != EOF){
functions[i] = func;
i++;
}
printf("%s\n", *functions); /* this is just for me to check if its working*/
}
incldues stdio.h, stdlib.h and string.h
SO the code works in that it runs through the file and during the while loop it stores the line but I want it so that functions[0] stores a pointer leading to the first line and functions[1] stores a pointer leading to the second line and so on. I'm not sure how to do this, any help would be appreciated thanks :)