Answer the question
In order to leave comments, you need to log in
std find algorithm not working for string?
string str{"fdsfs dfgdf dgf"};
auto find=std::find(begin(str),end(str)," ");
Answer the question
In order to leave comments, you need to log in
You are calling std::find , which is designed to find an element in the collection. And you try to look for a line there. This all almost compiles, because a string is a collection of characters, one could search for a single character on it. But you are passing a pointer (your string constant) there. The compiler cannot convert it to a symbol and swears at it.
For what you need, there is std::string::find . Those. you need to call str.find(" ")
.
Or look for a single character. Just do not forget to include algorithm, otherwise incomprehensible errors with iterators will come up.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question