char *ptr = malloc(sizeof(char));
printf("\nValue of ptr: %d\n",ptr);
printf("\nValue of address of ptr: %x\n",&ptr);
printf("\nValue of pointed by ptr: %c\n",*ptr);
printf("\nValue of address pointed by ptr: %x\n",&(*ptr));
*ptr='u';
printf("\nValue of pointed by ptr: %c\n",*ptr);
printf("\nValue of address pointed by ptr: %x\n",&(*ptr));
在上面的代码中,收到以下输出:
Value of ptr: 1046113600
Value of address of ptr: a2fffa78
Value of pointed by ptr: P
Value of address pointed by ptr: 3e5a6d40
Value of pointed by ptr: u
Value of address pointed by ptr: 3e5a6d40
这是否意味着具有单个字符大小的Malloc的缺省值是P?
已try 使用Malloc分配单个字符大小的内存,并初始化了指向已分配内存的指针.已try 打印分配的内存值.