reading data files

Could someone tell me what I am doing wrong? This is an old program I did and I just learned how to us data files but i can't get this ro read the data file. . I was told that the chars and interigers that was coming out of the data file did not need dedication. Is this true? I have tried it both ways. thank you in advance.

#include <fstream>

using namespace std;

int main()
{



//Declare string varibles


//Open the files
fin.open("inInfo.txt");
fout.open("outInfo.txt", ios::app);
if (!inIfo.txt)

//Initialize dint ch;
int ch1;
int sum;

//Get data from inInfo.txt
fin >> ch;
fin >> test2;
fin >> test3;



//mathmatical funtions

sum = test2 + test3;
fout << "The sum of"<< test2 << " and " << test3 <<"is" << sum;
fout << endl;
sum = test2 * test3;
fout << "The product of"<< test2 <<" and " << test3 <<" = " << sum;
fout << endl;



//Close the files
fin.close();
fout.close();


return 0;

}
try while loops when you extract the data from your files. that'll work
Topic archived. No new replies allowed.