question about reading files

how can i take numbers and characters from a file and put it into a variabel (in this case into an array).
i already know the basics of output to files (using ofstream) but how can i get certain part of a file, and store that into my program in a variabel? like the information for maps in a game engine for example
The easiest way is to play around with getline() function and if you know what to expect on the line where you get the info you just read whatever you need to read with myfile << number << character << something . Getline is also capable of reading the line till the certain character is met, default one is '\n'.
If you want something more sophisticated and own, well, read all characters into your own chars buffer and play with.
ah ok. il be sure to play with it. thats the best way to learn right ;)
file input and output works similar to the in/output to the cmd window right?
Yes, except cmd window is limited to how many lines it can display, wheres file is unlimited.
Topic archived. No new replies allowed.