csapp 练习2.60

2014-08-29 Mithrilwoodrat 更多博文 » 博客 » GitHub »

原文链接 http://woodrat.xyz/2014/08/29/csapp-%e7%bb%83%e4%b9%a02-60/
注:以下为加速网络访问所做的原文缓存,经过重新格式化,可能存在格式方面的问题,或偶有遗漏信息,请以原文为准。


<!--[CDATA[

#include

include

typedef unsigned char * byte_pointer; unsigned replace_byte(unsigned x,unsigned char b,int i); int main() { unsigned x = 0x12345678; unsigned char b =0xab; int i = 0; scanf("%d",&i); printf("%x",replace_byte(x,b,i)); return 0; } unsigned replace_byte(unsigned x,unsigned char b,int i) { unsigned temp = x; byte_pointer start = &temp; start[i] = b; return temp; }