Thursday, 19 September 2013

Reading in numbers with getline

Reading in numbers with getline

I have a line that has the format (int,int,int,char) and wish to store the
three ints into x,y,z and then place the char value into that position in
my 3D array. However it is skipping the first number and going to the
second. Any help?
void list_Input(char ***&a, const int &f, const int &n)
{
string line;
while (getline(cin, line, ',') && !line.empty())
{
if (line[0] == '/' )
{
continue;
}
else
{
int y = stoi(line);
getline(cin, line, ',');
cout << line;
int x = stoi(line);
getline(cin,line,',');
int f = stoi(line);
a[z][x][y] = getline(cin,line,')');
}
}
}

No comments:

Post a Comment