filling a 2-d array

Nov 1, 2011 at 8:36pm
ok, i dont know anyone who can help me. i've been trying to fill a 2-d array for a while now and all i have is this.

int FillArray (string a, string b[][6])
{
int x = 0;
ifstream file;//ofstream
file.open((a+".txt").c_str());
//file.open(a.c_str());
if (!file.is_open())
{
cout << "could not open" << endl;
return -1;
}

while (!file.eof ())
{
getline(file, b[x][6]);
x++;
}
return x;
}

i dont know if it works, but even if it does, it will only fill the boxes with lines and i need it in individual characters.

someone i know said to fill a string and then read the string into a for loop, but i dont know how to do that. i mean, i dont really know how to fill an array with a line from a text document.

does anyone know how to do this.
Nov 1, 2011 at 9:01pm
To input the data into that array - file >> b[x][6]
Nov 2, 2011 at 1:05am
ok, do you know how to fill a string with a line from a text document?

im assuming the file isn't just file. is it file(whatever.txt) >>b[x][6]
Nov 2, 2011 at 1:13am
@xsemel
Sorry, no, I don't. I've just learned how to fill arrays, int and char characters. Hopefully others that are far more knowledgeable in these matters can give pointers to you.
Nov 2, 2011 at 1:26am
oh well, thanks.
Topic archived. No new replies allowed.