network sites: arcadespot.com | animejolt.com
+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 26
  1. #1
    Spotter got spotted!
    Join Date
    Oct 2009
    Location
    In that place with that thing..
    Posts
    371

    Default [Release] Guessing Game v2

    I've always been a big fan of coding. I started learning how to code in C++ a few weeks ago, using various tutorials and stuff online. I coded a small game a while ago where the user has to guess a number which is randomly generated when the program starts. I started making small changes to it as I learned more about C++. For example, I modified it so it has three difficulty levels. The user could choose whether the number would be between 1 and 10, 1 and 50, or 1 and 100. They would then have 8 tries to guess the number. I then changed it so the user could choose to play again afterwards.

    Now, I made another small change. To practice reading and writing files, I made it output a log after certain actions are performed while the program is running. It's actually a bit trickier than it sounds.

    Anyway, here's the complete program. The executable (for Windows), and the source code!

    Download it from the attachments

    All comments and suggestions are welcome! And if there are any C++ masters out there, I'd appreciate it if you could give me tips on how to improve my practise

    NOTE:
    I coded and compiled this on Windows 7 Ultimate 32-bit with Microsoft Visual C++ 2010 Express Edition. Some headers used are only compatible with Windows, so sorry if you're using a different OS. I don't plan on trying to make everything OS-independent.
    Attached Files
    Last edited by SpotterMan; 08-19-2010 at 03:10 PM.




  2.    
  3. #2
    Retired
    Join Date
    May 2010
    Posts
    4,568

    Default

    Upon "Would you like to play again" either option takes me to "You have chosen not to play again - Press any button to exit"

    When a button is pressed, the whole thing just freezes.
    Last edited by Psyko; 08-18-2010 at 11:41 PM.

  4. #3
    Spotter got spotted!
    Join Date
    Oct 2009
    Location
    In that place with that thing..
    Posts
    371

    Default

    Odd. Tell me this: What operating system are you using? It seems to work perfectly fine for me. If you were to recompile the source code using your own compiler it would probably work just fine..




  5. #4
    Retired
    Join Date
    May 2010
    Posts
    4,568

    Default

    Windows 7 Ultimate, 32-bit.

    As for recompiling, hell no. I know nothing about coding and in all honesty I think the users should rely on the developer for bug fixes

    edit: how about the feature to let users select the amount of tries, ranging from 1 to 8?
    Last edited by Psyko; 08-19-2010 at 12:31 AM.

  6. #5
    Elite Poster
    Join Date
    Oct 2007
    Location
    New Zealand
    Posts
    369

    Default

    My graphic calculator can do this. I know it would contain Int(Ran#x100+1) don't know the rest though.

    Also known as:
    cryphakon
    badboy.mjk
    kempmjk

  7. #6
    Spotter got spotted!
    Join Date
    Oct 2009
    Location
    In that place with that thing..
    Posts
    371

    Default

    You're using the exact same OS as me Psyko. Not much I can say to help. I'll run through the code and see what happens that can cause a freeze.

    And yep, I can do that. I'll do it later today




  8. #7
    Member
    Join Date
    Aug 2010
    Location
    Germany
    Posts
    94

    Default

    The Window freezes, because you have a wrong syntax in GuessingGame.cpp. You have written "getch();" that's not right, "getchar();" is the right syntax. What for a C++ Standart you are using? פצ I prefer you to use the C++ standart from 1996. It's compatible with all OS.

  9. #8
    Spotter got spotted!
    Join Date
    Oct 2009
    Location
    In that place with that thing..
    Posts
    371

    Default

    Quote Originally Posted by cOOLsp0T View Post
    The Window freezes, because you have a wrong syntax in GuessingGame.cpp. You have written "getch();" that's not right, "getchar();" is the right syntax. What for a C++ Standart you are using? פצ I prefer you to use the C++ standart from 1996. It's compatible with all OS.
    I'm using a special header, conio.h. With conio.h you can use "getch();" And I'm sorry if it's not compatible with all OSs, but I'll only really be coding for Windows.

    EDIT:
    I tried getchar();. It doesn't work as good as getch(); for me... If anyone knows a way to make the program terminate as soon as ANY key is pressed, go ahead and tell me
    Last edited by SpotterMan; 08-19-2010 at 03:01 PM.




  10. #9
    Spot Veteran
    Join Date
    Sep 2007
    Location
    Westland Mi.
    Posts
    509

    Default

    I gave your program a try and, it works fine for me. Im running win7 Ultimate 32bit.

  11. #10
    Spotter got spotted!
    Join Date
    Oct 2009
    Location
    In that place with that thing..
    Posts
    371

    Default

    Quote Originally Posted by stwilliams420 View Post
    I gave your program a try and, it works fine for me. Im running win7 Ultimate 32bit.
    Glad to hear it works. Makes me wonder though, why didn't it work for Psyko?





 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts