Apr 29, 2010 at 6:10pm UTC
How would I go about opening a file and reading the data into two separate 1-dimensional string arrays.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
for (i = 0; i < SIZE; i++)
inFile >> Name[i];
inFile.open("Names" );
if (inFile.fail())
{
cout << "can't open file" << endl;
}
for (int i = 0; i < SIZE; i++)
{
Names[i] = 0;
}
There is one infile with 2 different sets of data in it.
Last edited on Apr 29, 2010 at 6:15pm UTC
Apr 29, 2010 at 7:35pm UTC
You're reading from the file before it's open.
And then after it's open, you're setting everything to null.
Is type is Name?
are you reading numbers or characters?
Apr 29, 2010 at 7:44pm UTC
Numbers or characters wouldn't matter since he is reading thing into string arrays they would be processed as characters. Unless that's the point you're trying to make in which case I come off sounding like a pompus clown.
Apr 29, 2010 at 8:12pm UTC
I am reading Names from an infile.
Apr 29, 2010 at 8:14pm UTC
Well, like I said, you're not reading anything from an infile in that code snippet.