Below is the method implemented to read from the input file and make it a linked list, I can see that there are two entries inserted from end of the linked list when I diplay the linked list, kindly solve it
I have called it from main() as :
Code:
parseFile(start, in); // start is the start pointer to the linked list
Code:
void parseFile(rectNode *record, ifstream &inFile){
float coOrdinate;
char comma;
if(!inFile.eof()) {
inFile >> coOrdinate >> comma;
record->point1.x = coOrdinate;
inFile >> coOrdinate >> comma;
record->point1.y = coOrdinate;
inFile >> coOrdinate >> comma;
record->point2.x = coOrdinate;
inFile >> coOrdinate;
record->point2.y = coOrdinate;
record->next = (rectNode *) malloc(sizeof(rectNode));
cout << record->point1.x <<"yes ";
parseFile(record->next, inFile);
}
else {
record = NULL;
}
return;
}
The input file is as:
Code:
0, 0, 10, 10
2, 2, 8, 12
339, 88, 444, 654