1-dimensional string arrays.

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
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?
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.
;-)
I am reading Names from an infile.
Well, like I said, you're not reading anything from an infile in that code snippet.
Topic archived. No new replies allowed.