954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

template list

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?

sfrider0
Junior Poster
149 posts since Oct 2008
Reputation Points: 16
Solved Threads: 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.

StuXYZ
Practically a Master Poster
680 posts since Nov 2008
Reputation Points: 760
Solved Threads: 138
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You