C中字符串函数指针

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void  fun( char  *t )
{  int i=0;
   char *p=t;
   printf("*p=%p\n",*p);
   printf("*p+1=%p\n",*p+1);
   printf("*(p+1)=%p\n",*(p+1));
   printf("*p+2=%p\n",*p+2);
   printf("*(p+2)=%p\n",*(p+2));
}  
int main()
{  char s[30];
   gets(s);
   fun(s);
   system("pause");
   return 0;
}

 

显示的41,42,43分别为十进制数的65,66,67,即ABC的数值。*P+1与*(P+1)的区别在于,*(P+1)指向的是字符串,但*P+1是按字符串一直字符串。

猜你喜欢

转载自blog.csdn.net/qq_18671205/article/details/89873572