头文件game.h
#ifndef __GAME_H__
#define __GAME_H__
#define COLS 3
#define ROWS 3
void init_game(char arr[COLS][ROWS]);
void display_board(char arr[COLS][ROWS]);
void player_move(char arr[COLS][ROWS]);
void computer_move(char arr[COLS][ROWS]);
char check(char arr[COLS][ROWS]);
#endif //__GAME_H__
// test.c//
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include "game.h"
int main()
{
char chess[COLS][ROWS];
char done = 0;
init_game(chess);
do
{
display_board(chess);
player_move(chess);
done = check(chess);
if (done != ‘ ‘)
{
break;
}
computer_move(chess);
done = check(chess);
} while (done == ‘ ‘);
if (‘X‘ == done)
{
printf("玩家赢\n");
}
else if (‘O‘ == done)
{
printf("电脑赢\n");
}
system("pause");
return 0;
}
#include<stdio.h>
int main()
{
int i = 0;
if (i == 10)
{
printf("%d\n", i);
}
else
{
printf("hhh\n");
}
return 0;
}
#include <stdio.h>
#include <assert.h>
#define __DEBUG__
#if 0
int main()
{
int i = 0;
int k = 0;
for (i = 0; i < 1000; i++)
{
if (i == 100)
{
__FILE__
__LINE__
__DATE__
__TIME__
__STDC__
#ifdef __DEBUG__
printf("file:%s line:%d i = %d", __FILE__, __LINE__, i);
#endif
}
}
system("pause");
return 0;
}
#endif
#include <stdio.h>
int main()
{
int a = 10;
int b = 20;
int *p = &a;
int *const q = &a;
q = &b;error
*q = 40;
int const *r = &a;
r = &b;
*r = 30; error
int const * const w = &a;
return 0;
}
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
char * my_strcpy(char *dest, const char *src)
{
assert(dest != NULL);
assert(src != NULL);
char *ret = dest;
while (*src != ‘\0‘)
{
*dest++ = *src++;
}
*dest = ‘\0‘;
while (*dest++ = *src++)
{
;
}
return ret;
}
int main()
{
char *p = "hello";
char name[10] = {0};
printf("%s\n", my_strcpy(name, p));
printf("%d\n", strlen(my_strcpy(name, p)));链式访问
system("pause");
return 0;
}
#include <stdio.h>
#include "game.h"
int main()
{
fun();
return 0;
}