The program is supposed to erase all whitespace and all chars past the whitespace from a string, but it just hangs the terminal.
Code:
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<fstream>
#include<list>
#include<numeric>
#include<map>
#include<iterator>
void removespaces(vector<string>& v){
for(int i=0; i<v.size(); ++i){
string::iterator it=find(v[i].begin(),v[i].end(),' ');
if(it!=v[i].end()){
v.push_back(v[i]);
it=find(v[i].begin(),v[i].end(),' ');
v[i].erase(it,v[i].end());
}
}
}
int main()
{
vector<string> words;
words.push_back("aa bb");
removespaces(words);
for(auto& f:words)
cout<<f<<'\n';
}