Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Simple question about fstream.

Author
Message
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 12th Mar 2009 00:14
I want to read values from a text file using fstream, but I want to read a specific line number and store each line number into an array.

For example my text file will look like this:


So line 1 is the version, line 2 is the tile layer, and 3 on are tile id's. I have it reading the WHOLE file properly, just how do I use getline or what ever to return one line at a time.

Then I can do a for loop to store each into an array, but I just don't understand getline lol.

Thanks in advanced.

I am working on a 2D Side Scrolling MMORPG, the journey is being blogged and I suggest you check it out. Will include all progress, road blocks even drama! http://exoengine.com/blog/
Lion Jin
18
Years of Service
User Offline
Joined: 24th Sep 2006
Location:
Posted: 12th Mar 2009 03:17
Several ways to do this ,First you can read all the content into the memory (using getline )and store them all into a string ,then you can use string's find function to find which data you want to store one by one.You can search in the internet ,I think there are many articles to explain this.

Here are some codes from my project.

Login to post a reply

Server time is: 2024-11-25 17:31:33
Your offset time is: 2024-11-25 17:31:33