结构体与指针的应用

时间:2020-08-04 15:03:17   收藏:0   阅读:81
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <string.h> struct Book { char name[20]; short price; }; int main() { struct Book b1 = { "C语言指针指南", 105 }; struct Book* pb = &b1; printf("书名:%s\n", pb->name); printf("价格;%d元\n",(*pb).price); b1.price = 100; printf("价格;%d元\n", (*pb).price); strcpy(b1.name, "C++"); printf("书名:%s\n", pb->name); return 0; }

原文:https://blog.51cto.com/14893161/2516628

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!