First
#include <stdio.h>
#include <string.h>
struct Hero {
int id;
char name[50];
int level;
int hp;
int mp;
char skill[50];
};
int main()
{
// 使用结构体
struct Hero hero1;
hero1.id = 1;
strcpy(hero1.name ,"张三");
hero1.level = 5;
hero1.hp = 500;
hero1.mp = 100;
strcpy(hero1.skill,"奇横三");
printf("%d\t%s\t%d\t%d\t%s\n",hero1.id,hero1.name,hero1.level,hero1.hp,hero1.skill);
return 0;
}
Second
#include <stdio.h>
#include <string.h>
typedef struct Hero {
int id;
char name[50];
int level;
int hp;
int mp;
char skill[50];
} Hero1;
int main()
{
// 使用结构体
Hero1 hero1;
hero1.id = 1;
strcpy(hero1.name ,"张三");
hero1.level = 5;
hero1.hp = 500;
hero1.mp = 100;
strcpy(hero1.skill,"奇横三");
printf("%d\t%s\t%d\t%d\t%s\n",hero1.id,hero1.name,hero1.level,hero1.hp,hero1.skill);
return 0;
}
End
~
记录留存
嗨~辰 发布了10 篇原创文章 · 获赞 0 · 访问量 68 私信 关注