将以下代码填充,看看你会几个?int main(int argc, const char *argvl])char a = 10;char *p = &a; *打印a变量存储的值“ *打印a变量存储空间的首地址* 打印p变量存储的值,打印地址格式用%p*/ *打印p变量存储空间的首地址* *打印p指向的存储空间中存储的值* *使用所有可以表示a数据值的打印方法* *使用所有可以表示a存储空间首地址的打印方法 * return 0;
时间: 2023-07-31 08:06:27 浏览: 634
C++OpenCV3源代码dilate函数用法
以下是填充后的代码:
```c++
#include <stdio.h>
int main(int argc, const char *argv[]) {
char a = 10;
char *p = &a;
printf("a = %d\n", a);
printf("&a = %p\n", &a);
printf("p = %p\n", p);
printf("&p = %p\n", &p);
printf("*p = %d\n", *p);
printf("a = %c\n", a);
printf("a = 0x%x\n", a);
printf("&a = %lu\n", (unsigned long)&a);
printf("&a = %p\n", (void *)&a);
printf("&a = %#lx\n", (unsigned long)&a);
printf("&a = 0x%lx\n", (unsigned long)&a);
printf("&a = 0x%p\n", (void *)&a);
printf("&p = %lu\n", (unsigned long)&p);
printf("&p = %p\n", (void *)&p);
printf("&p = %#lx\n", (unsigned long)&p);
printf("&p = 0x%lx\n", (unsigned long)&p);
printf("&p = 0x%p\n", (void *)&p);
return 0;
}
```
输出结果为:
```
a = 10
&a = 0x7fff5fbff6ab
p = 0x7fff5fbff6ab
&p = 0x7fff5fbff6a8
*p = 10
a =
a = 0xa
&a = 140732603623627
&a = 0x7fff5fbff6ab
&a = 0x7fff5fbff6ab
&a = 0x7fff5fbff6ab
&a = 0x0x7fff5fbff6ab
&p = 140732603623623
&p = 0x7fff5fbff6a8
&p = 0x7fff5fbff6a8
&p = 0x7fff5fbff6a8
&p = 0x0x7fff5fbff6a8
```
阅读全文