That's not a complete program. I can't tell if you have function prototypes or what header files you have included.
Lines 27-33: Why are you counting lines character by character?
Line 39-40: That's not valid C++. In standards compliant C++, an array dimension must be a compile time constant. Some compilers do allow this as a non-standard extension.
Line 45: You never reset the stream to the beginning. You're going to be at eof. clear resets the eof bit, but does not reset the position to the beginning.
Line 46: Do not loop on !eof(). This does not work the way you expect. The eof bit is set true only after you make a read attempt on the file. This means after you read the last record of the file, eof is still false. Your attempt to read past the last record sets eof, but you're not checking it there. You proceed as if you had read a good record. This will result in reading an extra (bad) record. The correct way to deal with this is to put the >> operation as the condition in the while statement.
1 2 3
|
while (cin >> var)
{ // Good cin or istream operation
}
|
Line 47: This reads only a single character into each name (position varies).
Line 61: This prints only a single character (position varies) from each name.