Sorry about the wrong thingamajigs and the lack of proper description. That was just example code to quickly show what I'm looking for.
What I'm actually doing is a loop on both x and y and I don't know how to read it without scanf. Here's what I've been trying:
Code:
for(int y=0; y<gridsize; y++)
{
cout << "Map the grid line " << y << endl;
for(int x=0; x<gridsize; x++) //a perfect square grid
{
while(grid[y][x] != 'O' && grid[y][x] != '.')
{
cin.get(grid[y][x]);
if(grid[y][x] != 'O' && grid[y][x] != '.') { cout << "Please enter a O or a ." << endl; }
cin.ignore(256, ' ');
}
}
}
But while I'm inputting data in the program, it gets all buggy with the newlines and the spaces. I want my program window to look like this:
Code:
Map the grid line 0
O b
Please enter a O or a .
O .
Map the grid line 1
...
Right now I can bug it out by doing something like this
Code:
Map the grid line 1
butt
Please enter a O or a .
Please enter a O or a .
Please enter a O or a .
Please enter a O or a .
O.O
... //The program is ok with this even though it has too many characters
With scanf, I can make sure I'm only reading one character and that there is a space inbetween, and if I typed something like "butt O" it would read b and O. I'm looking to do that with C++.