C/C++ 之 结构体(1)定义和赋值
2017-09-24 16:18
309 查看
结构体的定义和赋值
# include<stdio.h> //结构体定义 struct Student { int age; char name; float score; }; void main(void) { struct Student st = {14,'H',44.4}; //初始化和赋值 struct Student st2; //初始化 st2.age=15; //赋值 st2.name='J'; st2.score=34.3; printf("%d %c %f\n", st.age, st.name , st.score); printf("%d %c %f\n", st2.age, st2.name , st2.score); }
c中的结构体和java中的类有点相似。
相关文章推荐
- (C/C++基础)结构体_初始化_赋值_定义_声明
- C++可以这样定义结构体(为成员指定有效位数)
- (c++)定义一个结构体变量(包括年、月、日)。计算该日在本年中是第几天,注意闰年问题。
- C/C++中结构体定义的效率与内存浪费问题 的 理解与分析
- C++变量(C++变量定义、变量赋值、命名规则)
- C++ 结构体指针的定义
- c++数据类型(整型/浮点型/字符串/数组/引用/结构体(内存对齐)/类(虚函数))定义、所占字节数、最大最小值
- [c++] 初始化结构体 赋值结构体 输出结构体各成员
- C/C++中结构体的定义和typedef的使用
- C#的结构体中定义byte[]对应C++中char[]的方式
- 关于C/C++中的结构体赋值问题
- 问题十六:每位同学的信息学号、姓名、C++、高数、英语成绩,定义一个学生成绩的结构体数组。
- C/C++ 定义向量、赋值和使用
- 让我们来看一看C++ 二.对象的定义、初始化和赋值
- 初学c/c++——定义结构体(struct)
- C++中定义结构体对象提示没有合适的默认构造函数可用错误
- C++中的声明、定义、赋值和初始化
- opaque struct——c/c++如何隐藏内部结构体的定义?
- C++中的继承(3)作用域与重定义,赋值兼容规则
- c++里定义变量类型double a(0)是定义+赋值吗?