谁能告诉我为什么?
printf函数在输出的表列项时直接加变量名就可以了,为什么scanf函数要加取地址呢?printf函数也可以理解为从这个变量的地址开始读取输出数据啊!还有就是好像看到书上说的 对一个字符数组(比如char a[]),如果printf("%o\n",a)则输出地址,如果printf("%s\n",a)就输出字符串 为什么第一个是输出地址而不是将字符数组里的内容的0101当作八进制整数内容输出呢?
#include <stdio.h> int main () { char s[4][4]; int i; s[0][0] = 'a'; s[1][0] = 'b'; s[2][0] = 'c'; s[3][0] = 'd'; printf ("\n&s = %x *s = %x\n", (int) &s, (int) *s); for (i = 0; i < 4; i++) printf ("&s[%d] = %x s[%d] = %x &s[%d][0] = %x s[%d][0]=%x == '%c'\n", i, (int) &s[i], i, (int) s[i], i, (int) &s[i][0], i, (int) s[i][0], s[i][0]); char *p = s; *p = 'e'; printf ("\nAfter doing this: char *p = s; *p = 'e';\n\n"); printf ("&s = %x *s = %x\n", (int) &s, (int) *s); printf ("&s[0] = %x s[0] = %x &s[0][0] = %x s[0][0]=%x == '%c'\n", (int) &s[0], (int) s[0], (int) &s[0][0], (int) s[0][0], s[0][0]); printf ("p %s s *p %s *s\n\n", (int) p == (int) s ? "==" : "!=", (int) *p == (int) *s ? "==" : "!="); return 0; }