0

Well, this project I'm working on is a Pokedex Program for my little sister for her birthday.

Anyways, I have a file PokeList.txt, which I want to store every Pokemon next to their ID number.

The text file is:

1. Bulbasaur
2. Ivysaur
3. Venusaur
4. Charmander
5. Charmeleon
6. Charizard

The script is:

std::string Pokemon::ListPokemon() {
	std::ifstream file;

	std::string filename = "PokeList.txt";
	file.open(filename.c_str());

	if(!file.is_open()) {
		return "An error occured while trying to open PokeList.txt, file reading failed...\n";	
	}

	while(!file.eof()) {
	}

	file.close();
}

I need it to put each line in an array from the text file. So basicly it will put them in the array like:

array("1. Bulbasaur", "2. Ivysaur") etc...

Help please, thanks ;)

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by nbaztec
0

Well, this project I'm working on is a Pokedex Program for my little sister for her birthday.

Awww, so sweet. I used to love Pokemon. All 507 of them (not really all).

std::string line;
while(std::getline(file,line))
{
   //Here you go.
}

Edited by nbaztec: n/a

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.