Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning(disable:4996)
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "functions.h"
- int main()
- {
- printf("Welcome to ""Tic-Tac-Toe""!\n-----------------------");
- char playerOne[32];
- char playerTwo[32];
- printf("\nPlayer 1, state your name: ");
- fgets(playerOne, sizeof playerOne, stdin);
- strtok(playerOne, "\n");
- printf("\nPlayer 2, state your name: ");
- fgets(playerTwo, sizeof playerTwo, stdin);
- strtok(playerTwo, "\n");
- printf("-----------------------");
- char startNumbers[3][3] = {
- { '1', '2', '3' },
- { '4', '5', '6' },
- { '7', '8', '9' }
- };
- int turn = 0;
- while (turn < 9)
- {
- printGame(startNumbers);
- turn++;
- int usedSquare = 0;
- if (turn % 2 == 1)
- {
- printf("%s, in what square do you choose to put your X? ", playerOne);
- scanf("%d", &usedSquare);
- getchar();
- }
- else
- {
- printf("%s, in what square do you choose to put your O? ", playerTwo);
- scanf("%d", &usedSquare);
- getchar();
- }
- if (usedSquare > 9)
- {
- printf("That square does not exist! Try again...\n");
- turn--;
- }
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement