Hello All,
I am trying to read in a text file with the following format:
<int1>,<char1>,<char2>,<char3>,<char4>,<int2>
All data is seperated by a comma. Once I have the data, I am trying to output only <char1> & <char2> until end of file.
So, to get the data, I am using the getline function as follows:
Code:
#include <fstream.h>
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
int main()
{
char Circuit1[30], Circuit2[30], Conductor[30], Comments[50];
int Line, Number;
char FileName[20];
cout << "Enter the name of the file you want to open: ";
cin >> FileName;
ifstream Table(FileName);
while(!Table.eof()){
getline( Table, Line, ',' );
getline( Table, Circuit1, ',' );
getline( Table, Circuit2, ',' );
getline( Table, Conductor, ',' );
getline( Table, Comments, ',' );
Table >> Number;
Table.ignore( 200, '\n' );
cout << Circuit1 << "\t";
cout << Circuit2 << "\t" << endl;
}
return 0;
}
I get the following error, but not sure what I can do to fix it.
'getline' : undeclared identifier.
Any ideas?
Thanks!