c++ - Getline string input to create a word -
i have program receives input , goes character through character avoid white spaces. need each 1 of characters aren't white spaces , stores them in string word. someone told me getline stores each character, has memory: then create while loop has (!= ' ')condition , use string.append('x') function "add" each character string variable you've created until have word. i understand concept don't know how it. here simple application takes string , filters out spaces. // reading text file #include <iostream> #include <sstream> #include <fstream> #include <string> using namespace std; int main () { string input; stringstream filter; cout << "enter string \n"; cin >> input; for(int = 0; i<input.length(); i++){ if(input.at(i)!=' '){ //chech see space or not filter << input.at(i); //if not space add stringstream filter } } string outp