char *p = "abcd"; char *q[] = {"abcd"}; printf("%s\n",*p); //野指针 printf("%s\n",*q); //打印abcd
[此贴子已经被作者于2019-3-11 06:54编辑过]
[此贴子已经被作者于2019-3-11 06:55编辑过]
int n = 10; int * z = &n; //z指针变量保存了n的地址 char *p = "abcd"; //printf("%c\n",*p,); //将文字常量区"abcd"的首元素赋值地址赋值给指针变量p 通过*p只能打印出a 打印整个字符串用p char *q[] = { "abcd","bbcde" }; printf("%c\n",**q); //q保存a的元素地址 //通过一级指针*q打印abcd 通过二级指针**q打印a printf("%s\n",*(q+1)); //通过a的地址+1 打印bbcde
#include <stdio.h> int main() { char *p="printf(\"hello\\n\")"; printf("%s\n",p); printf("%c\n",*(p+5)); printf("%s\n",p+5); return 0; }