2021_2_10

结构体

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
struct Book
{
char name[20];
short price;
};

int main()
{
struct Book b1 = { "C语言程序设计",55 };
printf("书名:%s\n", b1.name);
printf("价格:%d元\n", b1.price);
return 0;

}

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
struct Book
{
char name[20];
short price;
};

int main()
{
struct Book b1 = { "C语言程序设计",55 };
struct Book pb = &b1;
printf("书名:%s\n", pb->name);
printf("价格:%d元\n", pb->price);
//printf("书名:%s\n", (
pb).name);
//printf("价格:%d元\n", (*pb).price);
//结构体变量 . 可以找到成员
//结构体指针->成员
return 0;

}

猜你喜欢

转载自blog.51cto.com/15099264/2624542
今日推荐