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

Google sheets equipment borrowing system -

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

c# - Convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.IList<>' -