Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ STL remove error

Tags:

c++

string

stl

I'm having trouble understanding where I went wrong with my code:

#include <iostream>

#include <string>

using namespace std;

int main(int argc, char* argv[]) {
    string str = "";
    cin >> str;
    remove(str.begin(), str.end(), ' ');
    cout << str;
    cin.ignore();
}

The error says "'remove': function does not take 3 arguments (C2660)"

like image 835
tr0yspradling Avatar asked Dec 06 '11 01:12

tr0yspradling


1 Answers

Try adding

#include <algorithm>

"algorithm" is an STL header containing a lot of functions, including std::remove, which the OP is trying to call. The error he got was because there is another function that takes a single argument, called "remove", which deletes a file.

like image 162
StilesCrisis Avatar answered Oct 20 '22 13:10

StilesCrisis