深入理解计算机系统第二版习题解答CSAPP 2.7

下面的函数将输出什么结果?

1 const char *s = "abcdef";
2 show_bytes((byte_pointer) s, strlen(s));

其中字母‘a‘~‘z‘的ASCII码为0x61~0x7A。

 

show_bytes()函数定义如下:

 1 #include <stdio.h>
 2 
 3 typedef unsigned char *byte_pointer;
 4 
 5 void show_bytes(byte_pointer p, int n)
 6 {
 7     int i;
 8     for(i = 0; i < n; ++i)
 9     {
10         printf(" %.2x", p[i]);
11     }
12     printf("\n");
13 }

 

将输出:61 62 63 64 65 66

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。