Thread: hiding numbers

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    57

    Unhappy 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;
    }
    =@-OmegatronO-@=

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    This problem has been addressed many times already
    http://www.cprogramming.com/cboard/s...der=descending

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    57
    terribly sorry to bother anyone im kinda new here
    =@-OmegatronO-@=

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    It's no bother at all, now you know that you can search previously asked questions

    -Prelude
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    57
    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"
    =@-OmegatronO-@=

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    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
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about random numbers
    By Kempelen in forum C Programming
    Replies: 2
    Last Post: 07-02-2008, 06:28 AM
  2. Writing unique numbers to an array
    By yardy in forum C Programming
    Replies: 6
    Last Post: 12-27-2006, 09:15 PM
  3. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  4. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 11:15 AM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 06:38 PM