typedef与struct
来源:互联网 发布:淘宝行业关键词 编辑:程序博客网 时间:2024/05/29 17:47
struct定义结构体的方式
第一种:
#include<stdio.h>int main(){struct {int a;} t;struct {int a;} t2;t.a=-1;t2.a=2;printf("%d%d\n",t.a,t2.a);return 0;}
使用struct { xxx; } t;直接定义结构体变量
第二种:
#include<stdio.h>int main(){struct node{int a;} t;struct node t2;t.a=-1;t2.a=2;printf("%d%d\n",t.a,t2.a);return 0;}
使用struct node {xxx} t;定义结构体node,同时定义个变量t
此后还可使用struct node这个标识符定义变量t2
typedef
typedef的使用语法为typedef 数据类型 标识符;
结合struct的用法一
#include<stdio.h>typedef struct{int a;}node;int main(){node t;node t2;t.a=-1;t2.a=2;printf("%d%d\n",t.a,t2.a);return 0;}
使用此种方式可以直接用标识符node定义变量
结合struct的用法二
#include<stdio.h>typedef struct NODE{int a;}node;int main(){node t;struct NODE t2;t.a=-1;t2.a=2;printf("%d%d\n",t.a,t2.a);return 0;}
可以使用标识符node或者struct NODE定义变量
以上代码gcc编译通过
0 0
- typedef 与 typedef struct
- typedef与typedef struct
- typedef struct与struct
- typedef struct 与struct
- typedef struct 与 struct
- typedef struct与struct
- struct 与 typedef struct
- struct 与 typedef struct
- typedef struct与struct
- typedef struct与struct
- struct 与 typedef struct
- struct与typedef struct
- struct与typedef struct
- typedef struct与struct
- struct与typedef struct
- typedef struct与struct
- struct与typedef struct
- struct与typedef struct
- How to resolve "your security settings have blocked an untrusted application from running" in Mac
- 三国佚事——巴蜀之危(全错排公式)
- Machine Learning Foundation Lecure 01 The Learning Problem 学习笔记
- RandomAccessFile
- Eclipse前台窗口后台进程的用法
- typedef与struct
- 解决cookie在本地无法写入的办法
- commons-net FTPClient API存取设计
- android:shape的使用
- 代码审查
- java.lang.IllegalStateException: Couldn't read row 0, col 6 from CursorWindow异常
- 动态判断合成视频,保留原音,混音音乐,设置音量大小
- Storm Found multiple defaults.yaml resources
- 电子商务