Ok so, i'm currently trying to make a application that performs similar to a game of hangman.
i currently have it set up to have the leader of the game choose a word, and when he/she types it in it stores it as a variable, and also stores the length to then tell the players later.
this is what i have right now:
what i have works just as i want it, but now i need to get to a point to where i can look directly to the string defined and find individual characters.Code:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int strikes; // to tell the plyers how many wrong guesses
int wordlength; //to tell plyers how long the word is
char guess; //what the players will be defining to play the game
char gameword[30]; //the designated word from the leader
cout<<"For Game Leader:\nEnter Game Word Here:";
cin.getline(gameword, 25); //leader of game enters the word of the game here
wordlength=strlen ( gameword ); //stores the length of the word into "wordlength"
if( wordlength>25){
cout<<"The Word You Entered Was Too Long For This Game\n";
cout<<"Please Try Another Word."; //checks to see if word will fit in the string allowed
}
else {
cout<<"CONGRATULATIONS! You Have Chosen A Valid Word\n";
cout<<"Now You Are Ready To Play The Game\n\n\n"; //tells the leader he/she has chosen a valid word, and it's time to play
}
cout<<"For Players:\nThe Game Word Has A Length Of "<<wordlength; //reveals the length of the game word to the players
cin.get();
}
as the title says, i'm fairly new to this. i understand the logic, of most things. SO am i able to analyze the string made by the leader of the game and have, when the player types a single character as their guess to tell the player tht yes or no the letter is there, and there if the letter is there where as in:
leader chooses hangman as the gameword
player chooses a
say yes, and position 2
then
player chooses x
i say no
and give them 1 strike(u have certain number left)