C++ fstream issue on XCode
A little background info. I have programmed C++ in Windows for the past 2 years, via DevCpp, before I switched to the Mac. I started using XCode v. 3.2. I started with simple test programs, to see if everything is working out.
I come across a little snag where I want to create an output file that spit out numerical values. The build was successful, no errors. However, when I use TextEdit, the values are not displayed/written. I have tried source file on a terminal, and it was a success (both build and the file displayed the values).
Here is the code:
#include <iostream>
#include <fstream>
using namespace std;
int main (int argc, char * const argv[]) {
char FileName20;
cout << "Enter File Name : " << endl;
cin >> FileName;
ofstream fout(FileName);
double a = 5;
double b = 6;
double c = a + b;
fout << "ALL YOUR BASE ARE BELONG TO US!\n";
cout << a << '\t' << b << '\t' << a-b << '\t' << c << endl;
fout << a << '\t' << b << '\t' << a-b << '\t' << c << endl;
return 0;
}
I would appreciate any suggestions/solutions to this scenario. Thank you.
Cheers
Charles
MacBook Pro, Mac OS X (10.6), XCode v. 3.2