结构体的基本使用
#include <stdio.h>
#include <string.h>
struct Student
{
int age;
char name[50];
int score;
};
int main(int argc, char const *argv[])
{
struct Student stu;
struct Student stu2 = {18, "mike", 59};
struct Student tmp;
tmp.age = 18;
strcpy(tmp.name, "mike");
tmp.score = 59;
struct Student *p;
p = &tmp;
p->age = 18;
strcpy(p->name, "mike");
p->score = 59;
(&tmp) -> age = 18;
(*p).age = 18;
p[0].age = 18;
return 0;
}
#include <stdio.h>
struct Student
{
int age;
char name[50];
int score;
};
struct Student
{
int age;
char name[50];
int score;
}s1 = {18, "mike", 59},s2;
struct
{
int age;
char name[50];
int score;
}s3,s4;
int main(int argc, char const *argv[])
{
printf("%d, %s, %d\n", s1.age, s1.name, s1.score);
return 0;
}