i have a program and was wondering if i could compare a variable of type firstword[4] to just word.
Example if(firstword[4]=secondword); i am writing hangman game and if the first word when its guessed completely and is same as secondword which is word to be guessed i want it to print congrats, else if not equal then print you lose
Hi, yes you can compare an element in an array to a variable of the element type
So
1 2 3 4 5
string aSimpleString;
string anArrayOfStrings[4];
...
if (aSimpleString==anArrayOfStrings[2])
..
is fine.
Note that where you have a series of if's on the same variable as in your code, a switch statement is often a good alternative.
See http://www.cplusplus.com/doc/tutorial/control.html - switch is discussed at the bottom of the page.