-
hiding numbers
Im doing this little bit of basic code and i kno that there are better ways of doing it but its just practice mu problem is that when Player 1 enters the secret number it displays on the screen
im wondering how i can make id display like ** or somthing can any one guide me in the right direction thanks in advance
int main(int argc, char* argv[])
{
int thenum = 0;
int count = 1;
int guess = 0;
cout << endl;
cout << "*****Welcome to the numbers game*****" << endl << endl;
cout << "This is a 2 player game (for now) " << endl << endl;
cout << "The rules are simple - have Player 1 choose a number between 1-100 and then Player 2 will try to guess the number in the least amount of guesses Ok!";
cout << endl << endl << endl;
cout << "Welcome Player 1 please enter you secret number: ";
cin >> thenum;
cout << endl;
cout << "Thank you now its time to guess Player 2 hope ur ready";
cout << endl;
do
{
cout << " Player 2 please enter your guess: ";
cin >> guess;
cout << endl;
if (guess < thenum)
{
cout << "Im sorry your guess was too low Pleast try again :)";
cout << endl;
}
else if (guess > thenum)
{
cout << "Im sorry your guess was too high Please try again :)";
cout << endl;
count++;
}
}
while (guess != thenum);
cout << "Very good you finaly got it!! ";
cout << endl;
cout << "it took you " << count << "tries, im afraid u wont make highscore with that cya";
return 0;
}
-
This problem has been addressed many times already
http://www.cprogramming.com/cboard/s...der=descending
-Prelude
-
:( terribly sorry to bother anyone im kinda new here:(
-
It's no bother at all, now you know that you can search previously asked questions :)
-Prelude
-
Ok.. Ichecked out some of the other threads but im having a hard time getting what i want out of them i mean as you can see the code i have posted is very simple im not really as far along as "printf(this) or strcpy(that) or whatever are those the things i should learn to acomplish the task or is there a more basic way of doing it
"I will in future check previous threads";)
-
The methods posted are actually the simplest way that I can think of, a good idea would be to look around for the functions you don't understand on http://www.rt.com/man and fiddle with them to see how they work. Once you understand the workings of each function the code that you read will become more clear.
-Prelude