Thread: My first Program: tell me what you think

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    4

    My first Program: tell me what you think

    this is a game of tic-tac-toe that i made it was my firstr attemt at writing a c++ program please tell me what you think

  2. #2
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    I'd like to try your game but dunno its rules... maybe I need a readme.
    Never end on learning~

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    - goto statements
    Don't use them. They're OK in special cases, but in a program of this size, they're not needed.

    - toe variable
    You can tidy your declaration of this variable like so:
    >toe[]={'1','2','3','4', etc

    - cout << "\033[2J";
    That didn't work properly on my system. There must be a safer equivalent.

    - cout<<toe[6]<<" | "<<toe[7]<<" | "<<toe[8]<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<< endl<<endl;
    Maybe a loop would look better?

    Code:
    if (toe[0]==b && toe[1]==b && toe[2]==b)
        w=1;
    if (toe[3]==b && toe[4]==b && toe[5]==b)
        w=1;
    Use "else if", that way once a match is found, the rest of the if stataments will be bypassed. This is a small and pointless efficiency change in a program of this size, but still good to know for future development.

    All in all, I've seen a lot worse tic-tac-toe programs, so it's a good start
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    It's cool.

    The keys is your numpad keys... That figured out

    try to put the keys on the screen before you play the game

    possible bug : if you choose the 1'st block, it gives a strange character.

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    4
    You can tidy your declaration of this variable like so:
    >toe[]={'1','2','3','4', etc
    i tred this but i got these too erors back
    error C2059: syntax error : ']'
    error C2001: newline in constant
    Code:
    toe[]={'1','2','3','4,'5','6','7','8','9'};
    can you tell me what i did wrong

    thanks biosninja i fixed what you found about the first square

    black: i am making in a in game help sequence that will tell you how to play i will post an updated version a soon as i get my erors fixxed

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Initliasing the toe variable...
    Code:
    #include <stdio.h>
    
    int main(void)
    {
        char toe[] = {'1','2','3','4','5','6','7','8','9'};
        int i;
        
        for (i = 0; i < sizeof (toe); i++)
            printf ("%c\n", toe[i]);
            
        return 0;
    }
    or
    Code:
    #include <stdio.h>
    
    int main(void)
    {
        char toe[9];
        int i;
        for (i = 0; i < sizeof (toe); i++)
            toe[i] = (char)(i + 1 + '0');
        
        for (i = 0; i < sizeof (toe); i++)
            printf ("%c\n", toe[i]);
            
        return 0;
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User
    Join Date
    Aug 2002
    Posts
    57
    I don't know why I'm crying. It just makes me happy when a newbie posts his game(didn't download it). I just wish atleast 50% of the world population would be programmers and not casual gamers who think graphics rule......
    "A Programmer being told to 'go to' hell sees the 'go to' part of the sentence as the worst part." - Master Foto

  8. #8
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    wtf are you talking about?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM