why won't this code work?

i have tried to create .txt files but the compiler doesn't create them.what am i missing?

#include <iostream>
#include <cmath>
#include <fstream>
#include <cstdlib>


using namespace std;

int main()
{
ofstream myfile;
myfile.open("newfile.txt");
myfile << "this text goes inside\n";
myfile.close();


system("pause");
return 0;
}
The compiler won't create the txt file. You have to run the program. The file will probably be created in the project directory. The location will depend on how you configured your project/workspace.
sorry, i meant run. when i run the script it doesn't create a new file anywhere.
not even in the project folder. another way i know i didn't work is because it
didn't display "enter any key to continue wrote the script in a win32 console.
Are you sure you are running it correctly?
I ran the program and it worked for me.
i opened a new console and it worked in the new one. thanx a lot guys!
Topic archived. No new replies allowed.