在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
#include <stdio.h> #include <string.h> struct Books { char title[50]; //char author[100]; //int book_id; }; int main(){ struct Books b1; strcpy(b1.title,"C语言"); struct Books *p1; p1 = &b1; strcpy(p1->title,"Java 语言!"); printf("Books title:%s\n",(*p1).title);//指针指向 (*p1).title (*p1) = b1; printf("Books title:%s\n",b1.title); return 0; } #include <stdio.h> #include <string.h> struct bookinfo { char *info; char *page; }; struct Books { char *name; int xh; struct bookinfo *pinfo; }; int main(){ struct bookinfo binfo = {"产地深圳","900"}; struct Books b1 = { "C语言",100,&binfo }; /*定义结构体指针*/ struct Books *p = &b1; printf("name:%s xh:%d info:%s page:%s\n",p->name,p->xh,p->pinfo->info, p->pinfo->page); return 0; }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论