If you want so, you can skip this boring background and head to the question.
Quite some time ago I stopped using C++ for a while and started doing some/much programming in C#, using SDL.NET and later my own library ManagedGL.
As I got interested in 3D more and more, and the C++ code in the 'MUD Game Programming' book looked really appealing again, I recently partially switched back to C++.
But now there's a problem: I never really used the C++ standard library besides some basic cin and cout. Even worse, I was actually coding C+classes, mainly using cstdlib.
Using the NeHe tutorials I game quite far, and it looks promising. Now I'm able to draw textured quads and such, I'm going to make a simple maze game - which generally really are 2D besides the graphics, which is nice, because I do know how to make games in general.
- question
The actual problem: string parsing. Let's say I have this file:
WWWWWWWWWWW
W*........W
WWWWWWW...W
W...@.....W
WWWWWWWWWWW
This is my map. A dot is nothing, a W is a wall, the @ is the start position, and the * is the end position, very simple, so to say.
In C#, I'd do it like this:
for(int y=0; y<mapHeight; y++)
string line = theFileReader.ReadLine();
for(int x=0; x<mapWidth; x++)
map[x,y] = createTheTileFromChar(line[x]);
I know how to change this array to a single-dimension array using the y*w+x thingy, but it's really about the string parsing - if you could call it so. How to do this in C++?, using std::string?
Then, I'd like to know in what ways these functions are available in C++:
TextStream.ReadLine() with std::istream
String.Trim() with std::string
String.Split() with std::string
Thanks!