typeof() test demo
2015-08-06 08:31
302 查看
typeof(x) y;
把y定义成x的数据类型;
其参数 x有2款类型;
1 表达式
// func为int类型, 即var为int类型变量
extern int fun();
typeof(fun()) var;
2 参数
typeof(int)
typeof(int *)
typeof(int *[4])
typeof(typeof(int *)[4])
typeof(*x) y;
typeof(*x) y[4]; //y是*x的数据类型, 该数据类型组成的数组;
把y定义成x的数据类型;
其参数 x有2款类型;
1 表达式
// func为int类型, 即var为int类型变量
extern int fun();
typeof(fun()) var;
2 参数
typeof(int)
typeof(int *)
typeof(int *[4])
typeof(typeof(int *)[4])
typeof(*x) y;
typeof(*x) y[4]; //y是*x的数据类型, 该数据类型组成的数组;
#include <stdio.h> #include <unistd.h> int fun() { } int main(int argc, char *argv[]) { //declare int a; typeof(int) a; //declare int *b; typeof(int *) b; //declare int *c[3]; typeof(typeof(int*)[3]) c; typeof(b) d; //declare expression; typeof(fun()) var; a = 3; b = &a; c[0] = b; var = 4; d = &var; printf("a %d, b %p, c[0] %d %p var %d d %d\n", a, b, *c[0], c[0], var, *d); return 0; } /* $ g++ typeofDemo.cpp -o td $ ./td.exe a 3, b 0x22cc64, c[0] 3 0x22cc64 var 4 d 4 */
相关文章推荐
- LeetCode Single Number II
- 利用Mono.Cecil动态修改程序集来破解商业组件
- LeetCode Single Number II
- 【OC06】类目、延展、协议、计时器(连载八)
- linux挂载光盘,U盘
- 登陆界面的完善
- MVC框架介绍
- 文件目录和库
- JavaScript权威指南_149_第15章_脚本化文档_15.10-其他文档特性-可编辑的内容
- Python编译器实现内幕:添加一个新语句
- 南邮 OJ 1464 Text Messaging
- Python编译器实现内幕:添加一个新语句
- 为何大多数人做出来的图表只是一坨屎?
- PHP register_shutdown_function函数详解
- JAVA基础一大堆0805线程
- UIButton和UITextfield
- 平日收集的理财信息
- hdu 5348 MZL's endless loop 2015 Multi-University Training Contest 5
- Android开发 如何将EditText里面的内容显示在textView里(代码未亲测,如有不足,请留言!)
- Git查看、删除、重命名远程分支和tag