3 Replies - 358 Views - Last Post: 05 November 2017 - 08:21 AM Rate Topic: -----

#1 alyjohn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-November 17

Please help: Tic tac toe without array

Posted 05 November 2017 - 03:25 AM

I am new at c programming Please help

    char a = '1';
    char b = '2';
    char c = '3';
    char d = '4';
    char e = '5';
    char f = '6';
    char g = '7';
    char h = '8';
    char i = '9';
    char choice = '.';
    int turnnumber = 0;





int main()
{  
    board();
    choose();
    turn ();
    getchar();
}

void board()
{
    printf("\n\t\t\t\t TIC-TAC-TOE \n");
    printf("INSTRUCTIONS: \n\n");
    printf("1. It is 2 players game.\n");
    printf("2. Player 1 = O and Player 2 = X\n");
    printf("3. Each player has to select number from 1 to 9.\n\n");

    printf("     |     |     \n");
    printf("  %c  |  %c  |  %c \n", a, b, c);
    printf("     |     |     \n");
    printf("_____|_____|_____\n");
    printf("     |     |     \n");
    printf("  %c  |  %c  |  %c \n", d, e, f);
    printf("     |     |     \n");
    printf("_____|_____|_____\n");
    printf("     |     |     \n");
    printf("  %c  |  %c  |  %c \n", g, h, i);
    printf("     |     |     \n");
}

void choose()
{


    printf("Please choose ");
    scanf_s("%c", &choice);
    getchar();
}

void turn()
{
    if (choice == a)

        char a = 'X';

    else
        char a = 'O'
}




    return 0;
}


This post has been edited by ndc85430: 05 November 2017 - 03:51 AM
Reason for edit:: Fixed code tags.


Is This A Good Question/Topic? 0
  • +

Replies To: Please help: Tic tac toe without array

#2 ndc85430  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 593
  • Posts: 2,490
  • Joined: 13-June 14

Re: Please help: Tic tac toe without array

Posted 05 November 2017 - 03:52 AM

What exactly do you need help with? You're going to need to ask a specific question - just posting some code without any details doesn't help anyone.

Also, please use code tags correctly in future. You can insert them using the "[CODE]" button in the editor.
Was This Post Helpful? 0
  • +
  • -

#3 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 1377
  • View blog
  • Posts: 4,318
  • Joined: 20-March 10

Re: Please help: Tic tac toe without array

Posted 05 November 2017 - 04:08 AM

Also is it a homework assignment or College / University assignment or other ?
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5898
  • View blog
  • Posts: 20,137
  • Joined: 05-May 12

Re: Please help: Tic tac toe without array

Posted 05 November 2017 - 08:21 AM

See here for tic-tac-toe without arrays: Just integers.

There is actually a better explanation of how to do this using bits of an integer, but it is in an out of print assembly programming book from the 70's. The article I linked to above hits the high points.

To not use the bits of an integer, the code to implement tic-tac-toe with arrays becomes an exercise in cut-and-paste, or macro magic.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1