Guest_imported
New member
- Jan 1, 1970
- 0
I'm having trouble reading strings from a file using scanf.
The file looks something like this:
Smith, John 8.5 8.0 9.0 9.5
It contains 15 different names.
This is how I tried to read one of the names(reading first and last name separately):
char name1[15][10];
char name2[15][10];
r = 0;
fscanf(in, "%s%s", name2[r],name1[r]);
when I do this, it gives me a Segmentation Fault. But when I remove the array subscripts I get a Bus Error. I do not know what to do, I have tried everything.
The file looks something like this:
Smith, John 8.5 8.0 9.0 9.5
It contains 15 different names.
This is how I tried to read one of the names(reading first and last name separately):
char name1[15][10];
char name2[15][10];
r = 0;
fscanf(in, "%s%s", name2[r],name1[r]);
when I do this, it gives me a Segmentation Fault. But when I remove the array subscripts I get a Bus Error. I do not know what to do, I have tried everything.