View Single Post
Old Sep 29th, 2007, 4:51 AM   #3
Soulstorm
Hobbyist Programmer
 
Soulstorm's Avatar
 
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3 Soulstorm is on a distinguished road
This is code from a class implemented into one of my frameworks. I hope it helps


#define std::string stdString
#define std::vector stdVector

void Floader::loadDataFromFile(const char *fileName){
	int i;
	resetData();
	stdString line;
	fstream myFile(fileName);
	for (i=0; myFile.good(); i++) {
		getline(myFile,line);
		loadedData.push_back(line);
	}
	
	myFile.close();
	stdCout << "Process completed\n";
}
The loadedData is a vector holding strings.

This will read a file and will make the vector hold each line of the file. I hope it helps.
__________________
Project::Soulstorm (personal homepage)
Soulstorm is offline   Reply With Quote