Guest_imported
New member
- Jan 1, 1970
- 0
Hi all,
I have a file containing records as follows:
1634 2439484 the guess who - Get Your Ribbons On
I need to load this into a linked list containg:" int, int char[256],char[256]". the split between the 2 chars is (obviously?) at the hyphen on the input file.I have been attempting all manner of fscanf arguments along the lines of the code given below, but I can not get the fscanf to add the white spaces.
Can anyone help me with this!
regards
Tom
----snip-----------------------------------
void read_file (void) {
INPUT* lstptr;
textfile = fopen("input.txt","r"
;
while(!feof(textfile))
lstptr = (INPUT*) malloc(sizeof(INPUT));
fscanf(textfile,"%s %s %s %s", lstptr->field0, lstptr->field1,
lstptr->field2, lstptr>field3);
rcdCtr++;
lstptr->next = endOfInputPtr
endOfInputPtr = lstptr;
}
fclose(textfile);
std::cout << "Records read in.... "<< rcdCtr <<'\n';
return;
}
-----snip--------------------------------------------------------
I have a file containing records as follows:
1634 2439484 the guess who - Get Your Ribbons On
I need to load this into a linked list containg:" int, int char[256],char[256]". the split between the 2 chars is (obviously?) at the hyphen on the input file.I have been attempting all manner of fscanf arguments along the lines of the code given below, but I can not get the fscanf to add the white spaces.
Can anyone help me with this!
regards
Tom
----snip-----------------------------------
void read_file (void) {
INPUT* lstptr;
textfile = fopen("input.txt","r"
while(!feof(textfile))
lstptr = (INPUT*) malloc(sizeof(INPUT));
fscanf(textfile,"%s %s %s %s", lstptr->field0, lstptr->field1,
lstptr->field2, lstptr>field3);
rcdCtr++;
lstptr->next = endOfInputPtr
endOfInputPtr = lstptr;
}
fclose(textfile);
std::cout << "Records read in.... "<< rcdCtr <<'\n';
return;
}
-----snip--------------------------------------------------------