Hey, so I'm new to C++ and XCode and I'm wondering why the following code won't work:
#include <iostream>
#include <fstream>
using namespace std;
int main (int argc, char * const argv[]) {
ofstream file;
file.open("test.txt");
file << 30;
}
Nothing is being output to the file. If I replace the int 30 with a string "30", it works fine. Everything I can find online says that this should work, so I have no idea what the problem is. Thanks.
#include <iostream>
#include <fstream>
using namespace std;
int main (int argc, char * const argv[]) {
ofstream file;
file.open("test.txt");
file << 30;
}
Nothing is being output to the file. If I replace the int 30 with a string "30", it works fine. Everything I can find online says that this should work, so I have no idea what the problem is. Thanks.