oops! I sent this to c# accidently, am I guilty of multiple posts with my first post?
read from .txt file & put into array?
Could someone give me a clue how to read a list of names (one per line )from a text file into an array (2d?) for use in a function.
I can open and close the file Ok. The file was written to with fprintf and I am trying to read from it with fscanf (using &) but my program keeps crashing. Heres a bit of it below
//function( ) simply prints the correct answer
char s; //crashing badly
f = fopen(datafile,"r"); //../correct_answers.txt
s[i] = fscanf(f,"\n%s",&s) ;
printf("rrrrr"); //this works but I need
//the answer from the file in here
The .txt file is as follows:-
The program is a CGI program and when invoked from the form
crashes. It works ok if I use string constants in the case statements but I cant get my answers from the text file into the case statements. I'm new to this, lost , lonely and confused.
Any clues to point me in the right direction would be much appreciated.