GameKiller - Bringing The Pain To Each And Every Game!
Reply to Thread
Results 1 to 3 of 3
  1. #1
    Leecher Feedback Score 0 adenibi's Avatar
    Join Date
    Jan 2010
    Posts
    9
    Thanks
    2
    Thanked 2 Times in 1 Post
     

    Default help with my first c++ program

    im not sure whats wrong with it but it wont compile could you guys give soem sugestions?? oo and if its not to much trouble if someone is willing to privatly tutor me on some basic c++ programs that would be awsome windowslive= adenibi xfire=adenibi aim=datboiiaj01

    program is below


    #include <iostream>

    using namespace std;

    int main (){

    system ("TITLE Guess my number");
    system ("COLOR 2");

    cout << "hey you, im alive! oh, and hello world!\n";
    system ("pause screen");{

    int guessednumber;
    int yesorno;

    cout << "my name is adenibi's first program\n";
    cout << "i want you to guess the number that im thinking of\n";
    system ("pause");

    cout << "the number that im thinking of is between 1-10 think you can guess it?\n";
    cout << "(y/n)lowercase only";
    cin >> yesorno;


    switch (yesorno)
    do
    {
    system ("cls");
    case 'y':
    cout << "so take your first guess";
    system ("pausse");
    cin >> guessednumber;
    cout << "you chose:" << guessednumber << "\n";

    system ("pause screen");

    switch (guessednumber)
    {
    case '6':
    cout << "Holy freakin crap dude u guessed my freakin number!!!!\n";
    cout << "dude you are AWSOME!!!\n";


    case '1':
    cout << "dude your gonna have to do better than that\n";
    cout << "try again\n";

    case '2':
    cout << "dude your gonna have to do better than that\n";
    cout << "try again\n";

    case '3':
    cout << "dude your gonna have to do better than that\n";
    cout << "try again\n";

    case '4':
    cout << "WOW you really suck\n";
    cout << "try again\n";

    case '5':
    cout << "BLOODY HELL your close but not quit there, how about a crumpet\n";
    cout << "try again\n";

    case '7':
    cout << "OH MY GOD THEY KILLED KENNY!!\n";
    cout << "GAME OVER\n";
    system ("pause screen");
    cout << "haha im just messing with you\n";
    cout << "you might wanna try again tho, wanna know why?\n";
    system ("pause screen");
    cout << "BECAUSE U PIK THE WRONG FUCKIN NUMBER!!!\n";

    case '8':
    cout << "OH MY GOD THEY KILLED KENNY!!\n";
    cout << "GAME OVER\n";
    system ("pause screen");
    cout << "haha im just messing with you\n";
    cout << "you might wanna try again tho, wanna know why?\n";
    system ("pause screen");
    cout << "BECAUSE U PIK THE WRONG FUCKIN NUMBER!!!\n";

    case '9':
    cout << "you might wanna try again\n";


    return 0;}

    }
    }
    }


  2. Sponsored


  3. #2
    Experienced Hacker Feedback Score 0 ヘ(^_^ヘ)(ノ^_^)ノ's Avatar
    Join Date
    Sep 2009
    Posts
    221
    Thanks
    4
    Thanked 43 Times in 28 Posts
     

    Default Re: help with my first c++ program

    First you want to put your code in [CODE][/CODE] brackets. It makes everything easier to read.

    system ("TITLE Guess my number");
    If you want to change the console window title use SetConsoleTitle(). Using system is bad practice. I don't think this is even a valid command.

    system ("COLOR 2");
    Once again if you want to change the console window color, use SetConsoleTextAttributes() and GetStdHandle(). Also I don't think this is a valid command.

    system ("pause screen");
    I don't think "pause screen" even dose anything. If you want it to pause, use something else. I recommend std::getchar() to start after getting input or Sleep() if you just want a delay.

    system ("pause");
    This is not wrong, but if you want to pause the screen read the above.

    system ("cls");
    WM_SETTEXT + PostMessage() for now. I forgot the other way to clear text.

    do
    {
    ...
    }

    Your statement is missing a while keyword and a condition.

    return 0;
    This should be right before your last curly bracket ( } ).

    case '6':
    cout << "Holy freakin crap dude u guessed my freakin number!!!!\n";
    cout << "dude you are AWSOME!!!\n";

    All your case statements are missing break keywords.

    case '1':
    cout << "dude your gonna have to do better than that\n";
    cout << "try again\n";

    case '2':
    cout << "dude your gonna have to do better than that\n";
    cout << "try again\n";

    case '3':
    cout << "dude your gonna have to do better than that\n";
    cout << "try again\n";

    Instead of having 3 of these, you should put them together.

    The RED is what keeps you from compiling.
    The YELLOW you will notice when you run your program
    The GREEN is just bad programming. Or at least the ones I can point out without changing your entire code.

    EDIT

    system ("pause screen");{
    You also have a { there for no reason.

    EDIT
    Now looking over your code, I see that you have a lot of pointless things in there. Like asking if they want to play your guessing game and then guessing a number. Why not just skip asking if they want to play and just make them guess the number. Then you only have 1 guess and its over. I also see a lot of senseless system("pause screen") in there. This is a text game, slowing the game down would be even worse.
    Last edited by ヘ(^_^ヘ)(ノ^_^)ノ; 01-23-2010 at 11:42 PM.
    Intel Corie i7 920 OC @ 4.0GHz + Prolimatech Megahalems CPU Cooler with 2 Fans @ 1200RPMs
    Evga X58 SLI Classified
    Evga GTX 470 FTW for 3 Way SLI + Evga GT 9800 GT for PhysX
    Corsair Dominator GT 1600MHz DDR3 6GB
    Corsair HX1000
    Corsair Obsidian 800D
    Kingston 64GB SSD for OS + Western Digital Caviar Black 1TB for Storage
    Alienware OptX 3D Monitor + Nvidia 3D Bundle
    Razer Lycosa, Mamba, Sphex, Mako, & Megalodon



  4. #3
    The New Guy Feedback Score 0
    Join Date
    Jan 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
     

    Default Re: help with my first c++ program

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main ()
    {
        int attempts;
        int guess;
        char yesorno;
        
        system ("TITLE Guess my number");
        system ("COLOR 2");
    
        cout << "hey you, im alive! oh, and hello world!\n";
        cout << "my name is adenibi's first program\n";
        cout << "i want you to guess the number that im thinking of\n";
        cout << "the number that im thinking of is between 1-10 think you can guess it?\n";
        cout << "(y/n)lowercase only\n";
        cin >> yesorno;
        
        if(yesorno == 'y')
        {
            for(attempts = 10; attempts >= 0; attempts--)
            {
                cout << "What is my number: ";
                cin >> guess;
                if(guess == 6)
                {
                    cout << "Winner!\n";
                    break;
                }
                else
                    cout << "Wrong! try again!\n";
                    cout << "You have " << attempts << " left.\n"; 
            }
        }
        else
            cout << "Fine dont guess my number.\n";
        fflush(stdin);
        getchar();
        return 0;
    }
    
    Fixed ur code.

    @ the guy above me. The things in red would still let him compile whether or not they are valid it would just display something like pause screen not recognized as a valid command.

    Also i dont recommended using SetConsoleTitle() because for what he is doing he have to add a whole nothing header file windows.h.
    Code:
    "Rob say Code Monkey very dilligent But his output stink."
    


Similar Threads

  1. gif program
    By zakk1 in forum Animated GFX
    Replies: 12
    Last Post: 10-02-2009, 01:24 AM
  2. Program Help
    By T3 in forum General Programming & Reversing
    Replies: 1
    Last Post: 08-16-2009, 09:04 PM
  3. gif program
    By zakk1 in forum Anime & Cartoons
    Replies: 2
    Last Post: 08-13-2009, 08:24 PM
  4. Is there a Program?
    By Gamekillaz in forum Counter-Strike General & Hacks Discussion
    Replies: 1
    Last Post: 08-04-2009, 01:35 PM
  5. Gif program
    By zakk1 in forum General Programming & Reversing
    Replies: 1
    Last Post: 08-03-2009, 03:39 AM

Visitors found this page by searching for:

Nobody landed on this page from a search engine, yet!
SEO Blog

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Winner for September 2010
GameKiller.net
Design Copyright © 2009 - 2010 GameKiller, All Rights Reserved.
GameKiller.net is not responsible for any content in any posting made by users on the site.
All times are GMT -4. The time now is 08:32 PM. SEO by vBSEO 3.5.1 PL1