-
string comparing
hi long time no c(++):confused:
i'm making a hangman in console
my problem is the following:
the user will have a word of lets say 10 letters
char word[10]={something};// should i use " " or ' ', ' ', ?
to think of then input a letter letter by letter
like
char input[0];
how can i check if this letter he has given exists
in the string word[10]
thanks in advance
-
Use the find method of the string class. I.e.
find (charT c, size_type pos = 0) const;
-
i tried all methods i could thiks of using the find function
but i dont get use of it
could u explain further
how do i find a character
in a string
i.e
char string1[6]="blabla";
char string2;
???
-
Sorry, your comment
>in the string word[10]
led me to think you were using the string class. Forget this because I see you are using char array strings.
Try 'strchr' instead, i.e.
char *strchr( const char *string, int c );
This will return NULL if the value of c is not found in string.
-
thanx man you've been very helpfull
-
pode,
Consider Davros' original thought of using a 'string'. You can still access specific char's using [], if you like, since a string is nothing but a char array with more functionality.
Might make life easier! :)
-Skipper