Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ Vectors

Name: Anonymous 2011-05-25 8:55

I got a function that adds to the vector which is

scores = new vector<string>;

void addToVec(string name, int score)
{
    scores->push_back(name);
    scores->push_back((char*)score);
    addToFile(scores);
}

then i want to add it to a output file with

void addToFile(vector<string> scores)
{
    ofstream outFile(SCORES_FILE, ios::app);
   
    if(outFile.fail()) {
        cout << "Could not write to scores file, exiting program" << endl;
        exit(1);
    }
   
    for (int i = 0; i < scores.size(); i++) {
        outFile << scores[i];
        outFile << " ";
    }
   
    outFile.close();
}

But i keep getting a "no matching function for the call 'addToFile(std::basic_string...etc etc"

My code all wrong?

Name: Anonymous 2011-05-26 7:15

You could get this language called Lisp and do the whole thing in 2 lines.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List