Read content from a text file

Hello good day!
I have a hard time if anyone can help me thank you:
It is as follows, I have a text file with the following lines:

name = idle
w = 60
h = 105
x = 61.0f
y = 0.0f
w = 62
h = 100
x = 63.0f
y = 20.7f
w = 78
h = 89
x = 67.0f
y = 25.0f
name = walkback

..... and so on ..
Open file: ifstream file ("some_file.txt");

Get first word ("name")
1
2
string word;
file >> word;

Get next word ("=")
file >> word;
Get next word ("idle")
file >> word;
Get next word ("w")
file >> word;

Each time you fetch a word, be sure to do something with it. Whatever it is you're doing with these values.

http://www.cplusplus.com/doc/tutorial/files/

Last edited on
Topic archived. No new replies allowed.