Whats the problem?

This code says the file is open, but it dose not actualy open, what is the problem?

1
2
3
4
5
6
  ofstream myfile ("example.bin", ios::out | ios::app | ios::binary);
            if (myfile.is_open()) { std::cout << "Open" << std::endl;}else{

                std::cout << "Nope" << std::endl;
}
if myfile.is_open is returning true, then the file is open.

What makes you think it isn't open?
It dose not actually open, I can not physically see the file, and I look in the folder that the exe is in and the whole project, and the file is not there... :/
It's somewhere. You're just not finding it.

Are you on windows?

EDIT:

If you're on windows, call this function wherever you create the file:

1
2
3
4
5
6
7
8
#include <Windows.h>

void whatDirectoryAmIIn()
{
    wchar_t path[2000];
    GetCurrentDirectoryW(2000,path);
    MessageBoxW(NULL,path,L"You are in this directory",MB_OK);
}


That'll pop up a message box telling you exactly what directory it's putting the file in.
Last edited on
Topic archived. No new replies allowed.