Reading from stdin to array

Hi. I've been stuck on this for hours and don't really know what to do.
I have a file that I have to read from stdin.

An example is
M //map mode
4 //Each room is N by N
2 //Number of rooms aka R
//blah blah can have comments wherever
//room 1
//room 0

My end goal is to make R-1 character arrays, containing the setup of each room.

Anyone have any tips for starting points. I've been looking around online and haven't gotten much done. I can't use fstream, just iostream.

Edit: What i am thinking right now is skipping to the rooms then reading N characters out and down, making that the R-1 array and repeating the process.

Now my current question is... After I read in the first 3 numbers. Lets say there are 5 lines of comments, each starts with //, how could I skip over this? My plan currently is

cin >> char
if char is /, skip the line and go to next. repeat

For skipping the line, I was thinking of using a getline to move to the next line. Would that work?
Last edited on
To read a commented line without problems:
void readcommentedline(std::string * output)
int position=output->find("//");
if (position==-1)
To use that:

(EDIT:Dealt with the case of there being no comment.)
Last edited on
Topic archived. No new replies allowed.