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:26

>>13
You don't need 2 lines, to add 2 vectors is as simple as: (map 'vector #'+ vector1 vector2)
Nevermind, I should have read the SEPPLES code that was missing code tags. The problem is so trivial that it's incredibly easy to do in just about any language.

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