Hey,
First of all, I am not a great programmer and lately I have not been having the best of luck getting my code to work (go figure!). Hopefully one of you will be able to help me out...
I wrote this code to open a txt file and print it to a screen, just to make sure it was opening the file in the first place. Once that is working, I need to take the variables from each line (5 in total, 3 char's and 2 int's). My question is, is there any reason that this code would not work? The program doesn't seem to do anything:
Code:
int main()
{
// ifstream constructor opens the file
char buffer[256];
ifstream Conductor( "tblConductor.txt" );
if ( ! Conductor.is_open() ) {
cout << "ERROR - File could not be opened\n";
exit(1);
}
while ( ! Conductor.eof() ) {
Conductor.getline(buffer, 100);
cout << buffer << endl;
cin.ignore();
}
return 0;
}
Also, I can not find any help for how to read in each of the lines of the tblConductor.txt file and assign the info to a variable in C++. Thanks in advance for your help.