1. 复合字面值
1
2
3
4 |
char
*get_status_str( int
status) { return
( char *[]){ "linkdown" , "partial-linkup" , "full-linkup" , "N/A" }[status]; } |
2. 常量折叠
1
2
3
4
5
6
7
8
9
10
11
12
13 |
#include <stdio.h> int main() { const
int a=9; int
*p=( int *)&a; *p=10; printf ( "%p %p\n" , &a, p); //0012FF7C 0012FF7C printf ( "a: %d , *p %d\n" ,a,*p); //a: 9 ,*p: 10 return
0; } |
具体参考:http://blog.csdn.net/yafeng_jiang/article/details/7101964
3. 系统里一些变量借来使用.
4. send recv并不是真正的发送接收,只是与socket缓冲区交互
5. 大小端转换
1 |
#define CHANGE_ENDIAN_DW(data) (data<<24 | data>>24 | data>>8&0xff00 | data<<8&0xff0000) |
随记-------不定期添加遗忘知识点,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/chagmf/p/3768427.html