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

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

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -