Thread: I have NO IDEA what I've done...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    11

    Question I have NO IDEA what I've done...

    Ok. I've got this Tic Tac Toe program to write for class, and so far this is what I have:

    /*Include Statements*/
    #include <stdio.h>
    #include <string.h>

    /*Data Structures*/
    struct GAME
    {
    char location[3][3];
    };

    /*Function Prototypes*/
    void displayboard(GAME pos);
    void setblank(GAME positionfunct);

    /*Main Function*/
    int main(void)
    {
    /*Variable Declaration*/
    GAME position;

    /*Sets all of the Mark Locations to a Blank Space*/
    setblank(position);

    displayboard(position);

    return 0;
    }

    void setblank(GAME positionfunct)
    {
    int a;
    for(a==0; a<3; a++)
    {
    positionfunct.location[0][a] = ' ';
    positionfunct.location[1][a] = ' ';
    positionfunct.location[2][a] = ' ';
    }

    return;
    }

    void displayboard(GAME pos)
    {
    printf("\n\t\t\t Columns");
    printf("\n\t\t\t 1 2 3\n");
    printf("\n\t\t\t | |");
    printf("\n\t\t\t 1 %c | %c | %c", pos.location[0][0], pos.location[1][0], pos.location[2][0]);
    printf("\n\t\t\t | |");
    printf("\n\t\t\tR =================");
    printf("\n\t\t\to | |");
    printf("\n\t\t\tw 2 %c | %c | %c", pos.location[0][1], pos.location[1][1], pos.location[2][1]);
    printf("\n\t\t\ts | |");
    printf("\n\t\t\t =================");
    printf("\n\t\t\t | |");
    printf("\n\t\t\t 3 %c | %c | %c", pos.location[0][2], pos.location[1][2], pos.location[2][2]);
    printf("\n\t\t\t | |");

    return;
    }



    Now, I know that all it is going(or should) do is display the empty board...but its not working right. When I try to run the program, it compiles and executes with no errors (VC++ 6.0), but then my screen will turn to this maroonish color, and the mouse will become an off white square. It goes without saying that I can't access anything during this and have no choice but to hit the reset button. I really don't see where my problems could be coming from? I mean, I understand that the code I have isn't great, but I'm learning about multi dimentional arrays on my own. I have no idea what is going on...I'm not fooling with the output in any way that should produce color, change the mouse, or even leave the little 80 character wide window.

    Please...help?

    - Pat

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Nope. It shouldn't be a problem with your code. Sounds like your computer and/or compiler is fubar. Can you compile other programs?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    11

    Yup...

    I've never had any kinds of problems like this before. My programs have always run right(once I work out all the coding bugs, that is. )...maybe I should just take it to school tomorrow and try it there...if it doesn't work on their Visual C++, my buddy has Turbo C++.......

    - Pat

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    11

    oh...

    and thanks for reading and replying to my mesage.

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Is this a typo?

    >>for(a==0; a<3; a++)

    If not there is your problem. You have not initialised the var 'a' and it could 'clear' some random mem location outside the allocated array.
    (You have asked IF it is zero not SET it to zero)

    Try

    for(a=0;a<3;a++)

    PS This T T T program is an assignment/question? It has been asked before here (I have tried to help someone else before). Do a search, you may find more code to help.
    Last edited by novacain; 11-19-2001 at 09:28 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. project idea ???
    By gemini_shooter in forum C Programming
    Replies: 2
    Last Post: 06-09-2005, 09:56 AM
  2. Have an idea?
    By B0bDole in forum Projects and Job Recruitment
    Replies: 46
    Last Post: 01-13-2005, 03:25 PM
  3. A little problem about an idea, help please
    By louis_mine in forum C++ Programming
    Replies: 3
    Last Post: 09-10-2004, 09:52 PM
  4. totally screwed up idea
    By iain in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 08-17-2001, 12:09 PM