R
Roy Gourgi
Hi,
I am trying to save information onto a file, but I have to have it print on
the screen first and then I would like to save it into the file. The problem
is that the information that I print on the screen is a bit different than
what is saved onto the file, but when I try to save it into a file, it saves
what is printed on the screen and not what I have in my SaveFile routine.
Here is an example of what the problem is in my program:
main()
{
cout << endl << "Line Number " << gnLineNumber << " Part Number " <<
gnPartNumber;
SaveFile();
stream=freopen("CON", "w", stdout);
}
SaveFile()
{
if((stream = freopen("aOutput.cpp", "a", stdout)) == NULL) exit(-1);
cout << endl << " Model Number " << gnModelNumber << " Line Number " <<
gnLineNumber << " Part Number " << gnPartNumber;
}
Instead of it printing what is in the SaveFile routine, it prints what is in
the main program in my aOutput file. What am I doing wrong?
TIA
Roy
I am trying to save information onto a file, but I have to have it print on
the screen first and then I would like to save it into the file. The problem
is that the information that I print on the screen is a bit different than
what is saved onto the file, but when I try to save it into a file, it saves
what is printed on the screen and not what I have in my SaveFile routine.
Here is an example of what the problem is in my program:
main()
{
cout << endl << "Line Number " << gnLineNumber << " Part Number " <<
gnPartNumber;
SaveFile();
stream=freopen("CON", "w", stdout);
}
SaveFile()
{
if((stream = freopen("aOutput.cpp", "a", stdout)) == NULL) exit(-1);
cout << endl << " Model Number " << gnModelNumber << " Line Number " <<
gnLineNumber << " Part Number " << gnPartNumber;
}
Instead of it printing what is in the SaveFile routine, it prints what is in
the main program in my aOutput file. What am I doing wrong?
TIA
Roy