Thread: Making a random number guessing game (exit failure? wtf)

  1. #31
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by muffinman8641 View Post
    What does !guess do? I know != is not equal to, so something related to that?

    It's like reverse psychology! You're a wizard!
    /thanks
    ! is logical NOT. Ie, it makes true false and false true.
    !true = false
    !false = true
    if (10 != 20) means if 10 is not equal to 20
    if (!(10 == 20) means if NOT 10 is equal to 20

    Quote Originally Posted by muffinman8641 View Post
    I have no idea what to do with this.
    What about the if ((atry > compguess) || (atry < 1)) { section?
    Sorry for being annoying, I'm just a little confused.
    Same here. We play a logical game.
    State the events that happens in the whole process when asking for user input.
    Ie, ask for input, if guessed > real ...
    This isn't difficult. Then you can easily translate that logic into code.
    Give it a try and reply if you have problems.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #32
    Registered User
    Join Date
    Jan 2011
    Posts
    87
    to do the hint thing you have to use mod or divide
    here is how to get places except ones:
    Code:
    placenumber = 10 // it can be 10 to any power but i will just use ten here
    cout << "the " << placenumber << "/'s place is " << compnumber % placenumber << endl;
    to get the ones is a bit harder (might be a better way to do this)
    Code:
    int temp = compnumber;
    while(temp < 10;
    temp -= 10;
    cout << "the ones place is " << temp << endl;

  3. #33
    Registered User muffinman8641's Avatar
    Join Date
    Feb 2011
    Location
    Eastern-Central PA
    Posts
    76
    Quote Originally Posted by bobknows View Post
    to do the hint thing you have to use mod or divide
    here is how to get places except ones:
    Code:
    placenumber = 10 // it can be 10 to any power but i will just use ten here
    cout << "the " << placenumber << "/'s place is " << compnumber % placenumber << endl;
    to get the ones is a bit harder (might be a better way to do this)
    Code:
    int temp = compnumber;
    while(temp < 10;
    temp -= 10;
    cout << "the ones place is " << temp << endl;
    My compiler says that the placenumber function is unrecognized. What header?

  4. #34
    Registered User
    Join Date
    Jan 2011
    Posts
    87
    sorry, placenumber should be:
    Code:
    int placenumber = 10;
    placenumber is used for the mod to take the excess off the left side of the number.

    here is a function to do everything you need. i found this at this link. all credit goes to the poster
    Code:
    char nthdigit(int x, int n)
    {
        while (n--) {
            x /= 10;
        }
        return (x % 10) + '0';
    }
    the previous snippets i wrote were written fast and sloppily, just to give you an idea
    Last edited by bobknows; 03-03-2011 at 07:45 PM.

  5. #35
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Geez. Don't hand out solution to problems!
    If I wanted to do, I could have done so. The reason I didn't is because I wanted muffinman8641 to learn how to do on his/her own. An exercise, if you will. You learn much more that way.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #36
    Registered User muffinman8641's Avatar
    Join Date
    Feb 2011
    Location
    Eastern-Central PA
    Posts
    76
    Once someone hands me the answer, I can practice it and learn it so I'll learn it.
    It doesn't have to be a riddle. :P
    (btw I'm a he, as indicated by muffinman8641)

    [Edit- as a matter of fact, the int placenumber=10 statement returns the ones place (not sure why).]
    Last edited by muffinman8641; 03-04-2011 at 10:17 AM.

  7. #37
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by muffinman8641 View Post
    Once someone hands me the answer, I can practice it and learn it so I'll learn it.
    It doesn't have to be a riddle. :P
    Unfortunately, you a minority in that.

    (btw I'm a he, as indicated by muffinman8641)
    The internet is an anonymous place. One cannot be sure of anyone's gender from a username alone. I rather not call someone by gender unless that someone declares it publically.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cygwin on win64
    By Vanzemljak in forum Tech Board
    Replies: 3
    Last Post: 01-12-2011, 04:28 PM
  2. Replies: 15
    Last Post: 10-20-2009, 09:39 AM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  5. non repeating random number generation?
    By gencor45 in forum C# Programming
    Replies: 1
    Last Post: 02-08-2005, 05:23 PM