Ok, I made a quick program to try to do that...it compiles and runs fine...but wont put out the information. What did I do wrong?
Code:
#include <fstream>
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
char fname[20];
char lname[20];
char idnum[10];
ifstream file;
file.open("info.txt",ios::in);
if(!file)
{
cout << "Unable to open!";
goto end;
}
while(file)
{
file >> fname >> lname >> idnum;
}
end:
file.close();
cout << "Firstname - " << fname;
cout << "\nLastname - " << lname;
cout << "\nID Num - " << idnum << "\n\n";
return 0;
}
//Textfile named 'info.txt'
//Contents of text file called 'info.txt':
/*
Justin Allen 01103657
*/