91837465839
91837465839

Reputation: 11

Getting error : invalid conversion from 'int' to 'std::ios_base::openmode'

I can't figure out why this isn't allowing me to save properly in NetBeans. It works perfectly fine in visual studios.

void scores(int x, Player users[])
{
    // Declarations
    fstream inScores;
    string line;
    string userName;
    int score;
    bool found = false;

    userName = users[x].userName;
    score = users[x].score;
        ```
    inScores.open("Scores.dat", ios::in | ios::out | ios::beg); 
        ``` 
    while (getline(inScores, line) && !found) {
        if (line.compare(userName) == 0) { //match strings exactly!
            found = true; // found is true => break loop
            inScores << score;
        }
    }
    inScores.close();
}

I expect the program to compile like it does in visual studios, however I have no idea why the same exact code doesn't compile in netbeans.

Upvotes: 0

Views: 1023

Answers (1)

Mike Vine
Mike Vine

Reputation: 9837

In this line:

inScores.open("Scores.dat", ios::in | ios::out | ios::beg); 

ios::beg is not a valid flag to pass into fstream::open

See this page for valid flags.

Upvotes: 2

Related Questions