#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
struct peo
{
char name[20];
char tele[12];
char sex[5];
int high;
}p1, p2;
//struct peo
//{
// char name[20];
// char tele[12];
// char sex[5];
// int high;
//}p3, p4;
//
//struct peo p5, p6;
//
struct st
{
struct peo p;
int num;
float f;
};
void print2(struct peo* sp)
{
printf("%s %s %s %d\n", sp->name, sp->tele, sp->sex, sp->high);//结构体指针->成员变量
}
void print1(struct peo p)
{
printf("%s %s %s %d\n", p.name, p.tele, p.sex, p.high);//结构体变量.成员变量
}
int main()
{
struct peo p1 = { "张三", "15596666666", "男", 175 };//结构体变量的创建
struct st s = { { "张三", "15596666666", "女", 166 }, 100, 3.14f };
printf("%s %s %s %d\n", p1.name, p1.tele, p1.sex, p1.high);
printf("%s %s %s %d %d %f\n", s.p.name, s.p.tele, s.p.sex, s.p.high, s.num, s.f);
print1(p1);
print2(&p1);
return 0;
}
标签:p1,struct,--,18,sex,high,peo,tele,结构
From: https://blog.51cto.com/u_16182079/6768801