What do you think is the loop condition in the following line?
while (ch = Infile.peek() != EOF)
[edit]Actually that whole loop is wrong.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
I think Borland Turbo C++ has a peek() function to peek into memory, but not into files. It looks to me that you mean to use get() to get a character from the file? I am not quite sure what you want to do after that.
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
you should anyway use ifstream instead of fstream for reading...
Omitting all errorchecking, the following will read and echo lines from a textfile:
#include <fstream>
#include <string>
#include <iostream>
#include <iomanip>
int main()
{
ifstream fs;
fs.open("test.txt");
string s;
while (fs >> s) cout << s << endl;
fs.close();
}
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
I assume you have 1 row of the array in each line of your input file, and the records (so columns in that row) are separated in some way that you can detect.
What you do is you use that criterion to split up the string you read (it reads a line at a time in my code) and fill the columns of your array with the resulting data.
So in pseudo code:
while no readerror on read line
split line
set columns
increase counter
wend
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337