嗨,我这里有一个读取输入行的代码。但是我需要帮助来忽略行中的制表符空格甚至空格。
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
string input;
string line;
cout<< "Enter the 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;
}
示例输入:
Hello my name is brownie
应该读
hellomynameisbrownie
我找不到办法。。