随笔分类 -  <深入理解计算机系统>

摘要:void reverse_array(int a[],int cnt){ int first,last; for (first = 0,last = cnt - 1;first < last;first ++,last –){ inplace_swap(&a[first],&a[last]); }} 阅读全文
posted @ 2012-11-07 09:28 flowjacky 阅读(988) 评论(1) 推荐(0)
摘要:若x != y,则: x = x ^ y ^ x;void inplace_swap(int *x,int *y){ *y = *x ^ *y; *x = *x ^ *y; *y = *x ^ *y;} 阅读全文
posted @ 2012-11-07 09:26 flowjacky 阅读(278) 评论(1) 推荐(0)
摘要:通过整型数组中间值的指针强制转换成字符指针来实现:int IPTest[3] = {0,513,0};char * CPTest = (char *)&(IPTest[1]); CPTest += 1; if (2 == *CPTest){ printf("Little endian\n");}else{ printf("big endian\n");} 阅读全文
posted @ 2012-11-07 09:24 flowjacky 阅读(141) 评论(0) 推荐(0)