I just started using Xcode and met with a very weird question while outputting results to file. Codes are follows:
#include <iostream>
#include <math.h>
#include <fstream>
using namespace std;
int main()
{
ofstream trial;
trial.open("trial.txt");
trial << "****" << endl;
trial << (5+3) << endl;
return 0;
}
The outputs in trial.txt are
****
I suppose to see 8 but it doesn't appear. However, the results are correct when output to console:
****
8
Does anyone have idea why it happened? Your help will be highly appreciated.
Best,
Stanley
#include <iostream>
#include <math.h>
#include <fstream>
using namespace std;
int main()
{
ofstream trial;
trial.open("trial.txt");
trial << "****" << endl;
trial << (5+3) << endl;
return 0;
}
The outputs in trial.txt are
****
I suppose to see 8 but it doesn't appear. However, the results are correct when output to console:
****
8
Does anyone have idea why it happened? Your help will be highly appreciated.
Best,
Stanley