>f = fopen(datafile,"r");
Always test that the file is open.
>for(i=0;i!=EOF;i++)
A better way would be to use an input function as the loop condition.
>s[i] = fscanf(f,"\n%s",&s) ;
fscanf returns the number of characters read as an integer, s[i] is a character array. You also try to pass the address of a char (*)[100] to fscanf where it expects just a char *.
Try something like this instead:
Code:
if ( ( f = fopen ( datafile, "r" ) ) == NULL ) {
perror ( "File open falure" );
exit ( EXIT_FAILURE );
}
for ( i = 0; fgets ( s[i], sizeof s[i], f ) != NULL; i++ ) {
/*
** Work with the line from the file.
*/
}
-Prelude