结构体类型怎么保存在一个变量 - 爱问答

(爱问答)

结构体类型怎么保存在一个变量

#include<stdio.h>

#include<windows.h>

 

struct test

{

int a;

int b;

char c;

char d[20];

};

 

void main()

{

struct test test1= {0};

char copy[20] ={0};

 

  test1.a = 1;

test1.b=2;

test1.c='a';

strcpy(test1.d ,"this is a test");

 

// int a1 =  test1.a;

// int b1 = test1.b;

// char c1 = test1.c;

       strcpy(copy,test1.d);

 

}


//  =====有//的地方请帮忙修正=====

结构体是一种用户自定义的数据类型,其实是一组相关变量的集合。例如,要存放学生的信息,包括学号,姓名,性别,成绩等,就可以用结构体变量。在c语言中定义结构体类型及变量如下。先定义结构体类型struct student{int num;char name[10];char sex;float score;};再用结构体类型定义结构体变量,struct student stu;结构体变量成员的引用。stu.numstu.namestu.sexstu.score

下一篇:电脑为什么总是自动重启?

上一篇:C++错误lnk2001什么意思,怎么处理,有时有,有时没有

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?