struct 中 typedef的用法
来源:互联网 发布:软件版本命名规则 编辑:程序博客网 时间:2024/05/05 22:15
大家都知道, 用struct定义一个结构体后, 每次用都需要打struct.
就如这样:
#include <stdio.h>
#include <stdlib.h>
struct student
{
int num;
char sex[10];
char name[20];
int score;
};
int main()
{
struct student stu[10];
return 0;
}
就如代码中的红字, 每次用student这个结构体, 都要在student前面加上struct, 这是很麻烦的, 那么有没有办法简化呢? 在c里面有一个typedef的关键字, 就可以简化。先看代码。
#include <stdio.h>
#include <stdlib.h>
typedef struct student
{
int num;
char sex[10];
char name[20];
int score;
}st;
int main()
{
st stu[10];
return 0;
}
就如代码上所示, 以后要用结构体student定义, 只需要打st就行了。 那么这个要怎么理解呢, st 其实就是student的 一个小名。 对 你听的没错, 每个人都有大名和小名, 叫大名是你, 叫小名也是你, 而typedef就是起起小名的作用, 这样就可以起到简化的作用了。
- struct 中 typedef的用法
- typedef struct的用法
- typedef struct的用法
- C/C++中typedef struct和struct的用法
- C/C++中typedef struct和struct的用法
- C/C++中typedef struct和struct的用法
- C++中typedef struct和struct的用法
- struct和typedef struct的用法
- struct和typedef struct的用法解析
- struct和typedef struct的用法
- typedef struct和struct的用法
- typedef struct和struct的用法验证
- typedef struct 在C和C++中用法的区别
- typedef的用法、struct和typedef struct的区别
- typedef的用法、struct和typedef struct的区别
- typedef的用法、struct和typedef struct的区别
- C/C++中typedef struct和struct的用法[转。不知出自何处]
- 转-struct和typedef的用法
- 哈尔滨、亚布力、雪乡-东升穿越、魔界、长白山、 松花湖冬捕、吉林双动7日游
- 系统提供的dispatch方法
- maven项目引用+反射+日志
- [LeetCode 17]Letter Combinations of a Phone Number
- 哈尔滨、亚布力、雪乡-东升穿越、魔界、长白山、 松花湖冬捕、吉林双动7日游
- struct 中 typedef的用法
- 山西凤凰山景区—植物园门票
- 在Android应用中使用自定义证书的HTTPS连接
- 十渡孤山寨—门票
- 如何将vbs脚本用VB封装为DLL,并在vbs脚本中调用
- libcurl ftp读取内存内容上传而不涉及到io操作
- [LeetCode 50]Pow(x, n)
- Android开源项目分类汇总
- Struts2的声明式异常处理