I decided not to call programs within a program just yet. However,
my program finally gives me the 4 highest numbers (on the screen) using:
Now I'm trying to get the program to write this info in a file. I first created / opened the file for reading using:Code:cout << indexoffirst << " = "<< first << endl << endl; cout << indexofsecond << " = " << second<< endl << endl; cout << indexofthird << " = " << third << endl << endl; cout << indexoffourth << " = " << fourth << endl <<endl;
Code:ifstream c_file ( "D:\\LotteryPrograms\\Fla_Mega_Money\\Highest_Frequencies.txt" ); if (!c_file ) { out << "Can't open input file" << " Highest_Frequencies.txt " << endl << endl; cin.get(); exit(1); }
I then opened the file for writing using:
I then try to write into the file using:Code:ofstream c_file ( "D:\\LotteryPrograms\\Fla_Mega_Money\\Highest_Frequencies.txt" ); if (! c_file ) { cout << "Can't open input file " << endl << endl; cin.get(); exit(1);
Code:c_file >> indexoffirst >> " = " >> first >> endl >> endl; c_file >> indexofsecond >> " = " >> second >> endl >> endl; c_file >> indexofthird >> " = " >> third >> endl >> endl; c_file >> indexoffourth >> " = " >> fourth >> endl >> endl;
but the writing is not happening... I get the following errors on build:
Code:Error 1 error C2371: 'c_file' : redefinition; different basic types Error 3 error C2088: '>>' : illegal for class 7 IntelliSense: no operator ">>" matches these operands
The part that I'm having trouble with is code:
Code:cout << indexoffirst << " = "<< first << endl << endl; cout << indexofsecond << " = " << second<< endl << endl; cout << indexofthird << " = " << third << endl << endl; cout << indexoffourth << " = " << fourth << endl <<endl; ifstream c_file ( "D:\\LotteryPrograms\\Fla_Mega_Money\\Highest_Frequencies.txt" ); if (!c_file ) { cout << "Can't open input file" << " Highest_Frequencies.txt " << endl << endl; cin.get(); exit(1); } ofstream c_file ( "D:\\LotteryPrograms\\Fla_Mega_Money\\Highest_Frequencies.txt" ); if (! c_file ) { cout << "Can't open input file " << endl << endl; cin.get(); exit(1); } c_file >> indexoffirst >> " = " >> first >> endl >> endl; c_file >> indexofsecond >> " = " >> second >> endl >> endl; c_file >> indexofthird >> " = " >> third >> endl >> endl; c_file >> indexoffourth >> " = " >> fourth >> endl >> endl;
Where am I wrong? . . . . therry



LinkBack URL
About LinkBacks


