File reading

Hi, I have a problem reading my text file.

I have a text file looking like:
113
213
322

and i want to read it into a vectors and get a result like:
map.at(0)= 1
map.at(1)= 1
map.at(2)= 3
map.at(3)= 2
map.at(4)= 1

and so on.

ifstream FileMap("Map.txt");
while(FileMap)
{
FileMap >> Map1;
map.push_back(Map1);
}

FileMap.close();

This is what I did but it don't seems to be working.

Sorry if my question is unclear... I am quite new to this. Any help is greatly appreciated. Thanks
The >> will take a continues string of numbers, so you're probably getting 113, 124, 322 instead of 1, 2, 3 ... You can use FileMap.get() to get one char at a time, but you will have to check if it is actually a number and not a new line.
thanks...

But it return a value no where near my text... 49.

ifstream FileMap("Map.txt");
while(FileMap)
{
Map1 = FileMap.get();
map.push_back(Map1);
}

FileMap.close();

is this what I am suppose to do?
is map is of type std::map. Can we do a push_back on map's.
Topic archived. No new replies allowed.