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

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -