I have to create a program that asks the user for a word clears the screen then lets the user guess the letters or the whole word so far i have it so that is clears the screen after the word is entered and if you want to guess the whole word you can, the problem is I dont know what to do with guessing single letters
this is what i have so far:
Code:
#include<iostream.h>
#include<console.h>
#include<string.h>
int main()
{
char secret[100];
char answer;
char answer2[100];
cout<<"Enter word: "<<endl;
cin>>secret;
clrscr();
for(int i=0; i<secret.length(); i++)
{
cout<<"-";
}
cout<<endl;
do{
cout<<"Enter your guess($ to guess the whole word and * to quit): "<<endl;
cin>>answer;
if(answer=='$')
{
cout<<"Enter your guess for the whole word: ";
cin>>answer2;
if(strcmp(secret, answer2))
cout<<"incorret, guess again"<<endl;
else
cout<<"You are right!";
}
}while(answer!='*');
return(0);
}
I need to make the output something like
----
-a--
ca--
etc.
I also wanted to use secret.length(); to print the intial dashs of how long the word was but I cant get it to work
Any help is apprieciated
thank you