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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

java - Log4j2 configuration not found when running standalone application builded by shade plugin -

python - How do I create a list index that loops through integers in another list -