asvalk1672
asvalk1672

Reputation: 95

Why doesn't ofstream create a new file?

I have a problem where ofstream isn't creating a text file. I compile and run the program just fine with no errors and I am 100 percent certain that I am in the right directory and that there are no spelling mistakes or errors. What is strange is when I move my program to my C drive or onedrive folder, then the text file is created, it just doesn't work in any of my other folders. I don't know what the problem is and I have scoured the internet for the past couple hours trying to find a solution, but I think it has something to do with my file permissions perhaps?

Here is my code, it's just a really simple program:

#include <iostream>
#include <fstream>

using namespace std;

int main() {

    ofstream myfile;
    myfile.open("newnumbers.txt");

}

Upvotes: 0

Views: 125

Answers (0)

Related Questions