码迷,mamicode.com
首页 > 其他好文 > 详细

结构体与指针的应用

时间:2020-08-04 16:44:03      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:++   std   string   har   指针   c语言   rcp   clu   print   

#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; }

结构体与指针的应用

标签:++   std   string   har   指针   c语言   rcp   clu   print   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!