0

I'm trying to figure out how to do template lists. I have this

GList<int> list1;
	GList<float> list2;
	GList<string> list3;
	ifstream inFile;
	inFile.open("data.txt");
	while(!inFile.eof()){

The code keeps going but that is about all that is important. The data.txt consists of ints, floats, and strings, which are separated by "I"'s, "F"'s, and "S"'s. I'm trying to store the data type in the correct list. I know that I need to find an "I", then get the next item after it, which is an int, and do that for the floats and strings. Would I store the data.txt in a sting, then someway get the info from that? I've tried that way but I just get the can't convert to int error. Any suggestions?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by StuXYZ
0

From the slightly overly-short section of code, (please post the rest of the while(!inFile.eof()) {.... })

I am guessing that you do not actually read any file.
inFile.eof() only checks the state of the file (it is not at the end)
If you do not have a readline / operator>> / getc or some such function, your file never advances and the while condition is always true.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.