I am having difficulty reading the following input file
Jon 40
Chris 50
Pete 60
what is wrong with this code that I wrote to read the above file. thank you for your help.
//*****************
#include <iostream>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <iomanip>
#include<cassert>
using namespace std;
void main()
{
char InputFileName[] ="in.txt";
char OutputFileName[]="out.txt";
ifstream InFile;
ofstream OutFile;
InFile.open(InputFileName);
if(!InFile)
{
cout<<"Not Open"<<endl;
exit(1);
}
OutFile.open(OutputFileName);
if(!OutFile)
{
cout<<" Can not Open output file"<<endl;
exit(1);
}
char c;
string name;
int age;
while(!InFile)
{
InFile>>name>>age;
OutFile<<name<<" "<<age<<endl;
if(InFile.eof()) break;
}
InFile.close();
OutFile.close();
}
<< moderator edit: added [code][/code] tags >>