How to remove commas from string in C++

1 Answer

0 votes
#include <iostream>
#include <algorithm>

int main() {
    std::string s = "32,746,190";
    
    s.erase(std::remove(s.begin(), s.end(), ','), s.end());

    std::cout << s;
}



/*
run:

32746190

*/

 



answered Feb 14, 2022 by avibootz
...