I'm having a simple i/o with file problem. I have the name coming from a string but it just wont open at all. Incoming code:

string notename[] = {"NULL","empty"};
ifstream readnote;

readnote.open(notename[x].c_str(),ios::in|ios::out);
        if(!readnote)
        {
            cout << "Read Error";
        }

its prolly something small but i keep getting the error, can u see it?

What's the value of x? Neither of the values in notename suggest a valid file name, and if they do, you'd need to verify that the file is in the current working folder. I'd suggest trying perror to get more information on why the file didn't open successfully:

if (!readnote)
{
    perror("Read Error");
}

You can find perror in stdio.h.

x = 1;
oh god i feel like such a idiot... forgot the folder place of the file...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.