- 日時: 2024/04/23 15:45
- 名前: 大魔王 (ID: egT9xB22)
学習用にスレッドを使っています。
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h>
typedef struct {
int hp;
int atk;
int def;
char name[64];
} player;
typedef struct {
int hp;
int atk;
int def;
char name[64];
} enemy;
void player_status_print(player data);
void player_status_print2(player *pdata);
void enemy_status_print(enemy data2);
void enemy_status_print2(enemy* pdata2);
int main(void) {
player data; player* pdata; enemy data2; enemy *pdata2;
pdata = &data; pdata2 = &data2;
strcpy(data.name,"勇者"); data.hp = 999; data.atk = 999; data.def = 999;
player_status_print(data);
strcpy(data2.name, "魔王"); data2.hp = 500; data2.atk = 500; data2.def = 350;
enemy_status_print(data2);
pdata -> hp += 999; pdata->atk += 999; pdata->def += 999;
player_status_print(data);
data.hp += 999; data.atk += 999; data.def += 999;
player_status_print2(&data);
pdata2 -> atk += 50;
enemy_status_print(data2);
data2.atk += 50;
enemy_status_print2(&data2);
}
void player_status_print(player data) {
printf("名前:%s\nHP:%d\nATK:%d\nDEF:%d\n\n", data.name, data.hp, data.atk, data.def);
}
void player_status_print2(player *pdata) {
printf("名前:%s\nHP:%d\nATK:%d\nDEF:%d\n\n", pdata->name, pdata->hp, pdata->atk, pdata->def);
}
void enemy_status_print(enemy data2) {
printf("名前:%s\nHP:%d\nATK:%d\nDEF:%d\n\n", data2.name, data2.hp, data2.atk, data2.def);
}
void enemy_status_print2(enemy *pdata2) {
printf("名前:%s\nHP:%d\nATK:%d\nDEF:%d\n\n", pdata2->name, pdata2->hp, pdata2->atk, pdata2->def);
}
|