Mail Archives: djgpp/1998/01/15/01:18:30
I receive a run time error in HEX when I attempt to read a data file
consisting of 2 lines with the following code.
Any help on proper use of the getline routine would be appreciated.
(note: the code extracts the first line of the file without error if I
don't use the second getline request to try to get the second line
in the file).
Please reply to my email address.
#include <iostream.h>
#include <fstream.h>
int main()
{
ifstream inFile = "test3.dat"; //test3.dat contains 2 lines for input
char * ptr_line1;
char * ptr_line2;
inFile.getline(ptr_line1,50,'\n');
inFile.getline(ptr_line2,50,'\n');
cout << ptr_line1 << endl;
cout << ptr_line2 << endl;
return 0;
}
- Raw text -