I made a program, hangman. And I am trying to complete it. I have succesfully been able to compare the input letter by all the characters of the word to be guessed (which is saved in an char array) and display it. But now, I can not figure out how to detect the absence of a character in a srting. So that I can add it to the array of the wrongly guessed letters. Your help will be greatly appreciated.
khuzdaar 0 Newbie
Recommended Answers
Jump to PostIf you do not find it, it is not there.
Jump to PostIf you're using a
std::string
then you can use itsfind
method, which returnsstd::string::npos
if the character you're looking for isn't there. If you're using achar
array then you can usestd::find
from the STL<algorithm>
library:#include <algorithm> …
All 6 Replies
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
NathanOliver 429 Veteran Poster Featured Poster
khuzdaar 0 Newbie
ravenous 266 Posting Pro in Training
khuzdaar 0 Newbie
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.