how to look at each character of a string without for loop in C++

Feb 4, 2017 at 9:41pm
Suppose I have a character, and I want to check if the character is in the string. For example, I want to know if 'a' is in the string "artifact" without using loops. I was wondering if there is a predefined function that checks each character of a string with the character provided and returns a bool.
Feb 4, 2017 at 9:49pm
There is string::find that returns the position where the string is found.
http://www.cplusplus.com/reference/string/string/find/
Feb 4, 2017 at 10:02pm
closed account (E0p9LyTq)
You can use either std::string::find or std::find from the <algorithm> header.

http://www.cplusplus.com/reference/algorithm/find/

Either reference have examples you can use and adapt to suit your needs.
Topic archived. No new replies allowed.