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
Post a Comment