c++ - string.find(" ") is not finding spaces -
i'm trying find space in string user inputs. want use find() std::string return position of space.
if input "seattle, wa usa", , want find(" ", 0) return 8, how this? 8th space after ","
string inputstring = " "; cout << "enter string modify" << endl; cin >> inputstring; int spac = inputstring.find(" " , 0); but find() keep returning 0. not sure why.
you're not reading space (cin >> inputstring stops on whitespace...).
use std::getline(std::cin, inputstring) instead.
Comments
Post a Comment