I am trying to read a file to create the structures for a small 2d game.
I am reading in integer numbers to construct the walls.
At the moment I am using getline and have each number on a seperate line
But I want to be able to read each box (four walls) on the same line
What syntax can I do this with?
Below is my current code
Code:
int i,j,readAmount;
string inputLine;
ifstream worldFile;
worldFile.open("map.2d",ios::in );
getline(worldFile,inputLine);
readAmount = atoi(inputLine.c_str());
for(j=0;j<readAmount;j++)
{
for(i=0;i<8;i++)
{
getline(worldFile,inputLine);
rectWalls[i] = atoi(inputLine.c_str()); //converts inputLine string Var to integer, via c to c++ conversion
}
polygon(mapBuffer,4, rectWalls, makecol(255, 0, 0));
}