
C语言
freeprisoner
本质的追求者
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C语言偏移任意指针量
刚刚有个朋友在群上提出一个问题,解决的方法需要指定指针偏移量。 比如: int a[] ={1,2,3,4}; int * p = &a[0]; p++; 其实编译器为了保证指针p正确地指向下一个int 型数据类型,会自动进行调整: p = p + sizeof(int); 一般来说,这是在p的位置上偏移4个字节(int 型 一般是4个字节)。那如果我要让p偏原创 2013-06-04 23:25:22 · 1416 阅读 · 0 评论 -
C语言中的函数指针
打开去年6月的一个test.cpp文件,发现对里面测试的函数指针几乎没有印象了。温故而知新, 于是重新找到ANSI C 里面的说明: 除了声明指向整型数字、双精度型数字和C语言其他数据类型的指针外,指针也能够被声明指向一个函数(包含一个函数的地址)。指向函数的指针是可能的,因为函数名像数组名一样,它们本身是指针常量。例如,首部行: int (*cal) () 声明calc是指向原创 2013-06-05 22:43:26 · 463 阅读 · 0 评论 -
same operation in multiple if statement, how to reduce code redundancy
I'm using Linux, and don't want to install Chinese input method, so I'm going to write this diary in English. Server days ago, I was asked to reduce code redundancy (see below) in a job interview. c原创 2014-03-13 23:42:41 · 532 阅读 · 0 评论