c++ - how to read a line ignoring the tab spaces -


hi have code here reads input line. need in ignoring tab spaces come in line or white spaces.

#include <iostream> #include <sstream>   using namespace std;  int main() {  string input; string line;  cout<< "enter input line" << endl;  while (getline(cin, line))    // while(cin >> line) {    stringstream in;   in << line;   //cout<<"what goen in: " <<in<<endl;   line = in.str();    input = line ;   cout<<"input is:" << input <<endl;  }   cout<< "the input entered was: "<<endl;  cout<< input<< endl;  } 

example input:

hello                 name brownie 

should read

hellomynameisbrownie 

i unable find way..

you may try remove tabs , whitespace line read follows:

 #include <algorithm>  using namespace std;  input.erase(remove(input.begin(), input.end(), '\t'), input.end());  input.erase(remove(input.begin(), input.end(), ' '), input.end()); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -