The following code worked just fine.
Code:
ofstream d_file ( "D:\\1_LotteryPrograms\\1_Fla_Mega_Money\\High_Freq.txt" );
if (! d_file )
{
cout << "Can't open input file " << endl << endl;
cin.get();
exit(1);
}
d_file << "The 4 numbers having the Highest Frequencies are:" << endl << endl;
d_file << indexoffirst+1 << " = " << first << ", " << indexofsecond+1 << " = " << second << ", " << indexofthird+1 << " = " << third << ", " << indexoffourth+1 << " = " << fourth << endl <<endl;
d_file << endl << endl;
d_file.close(); // Close the file stream explicitly
cout << "The 4 numbers having the Lowest Frequencies are:" << endl << endl;
cout << indexoflowest+1 << " = " << lowest << ", " << indexofsecondlowest+1 << " = " << secondlowest << ", " << indexofthirdlowest+1 << " = " << thirdlowest << ", " << indexoffourthlowest+1 << " = " << fourthlowest << endl <<endl;
If I stop the program here with a *cin.get()* and check the file, It was written into just fine. However, If I remove the *cin.get()* to let the program continue,
Code:
ofstream out1;
out1.open ( "D:\\1_LotteryPrograms\\1_Fla_Mega_Money\\High_Freq.txt" );
if (! d_file )
{
cout << "Can't open input file " << endl << endl;
cin.get();
exit(1);
}
d_file << "The 4 numbers having the Highest Frequencies are:" << endl << endl;
d_file << indexoffirst+1 << " = " << first << ", " << indexofsecond+1 << " = " << second << ", " << indexofthird+1 << " = " << third << ", " << indexoffourth+1 << " = " << fourth << endl <<endl;
d_file << endl << endl;
d_file.close(); // Close the file stream explicitly
not only does not update the file with new data, it erases the file, leaving it empty. I thought that
Code:
ofstream out1;
out1.open ( "D:\\1_LotteryPrograms\\1_Fla_Mega_Money\\High_Freq.txt" );
was supposed to open the file, write to it without erasing anything that was in it.
As far as your reading assignments, I thank you, however I have already read everything that I could fine on the subject. Much of it is so tech, that it leaves me confused. Please remember that I'm too new to C++ to be comfortable with the readings... but, I'm learning. . . . anyway, I'm greatful for your help!!!