小白初学,不懂这串指针代码的输出为什么这样
输出居然是4432
。
程序代码:#include<stdio.h>
int main()
{
char s[]="1234",*p;
p=s;
printf("%c%c%c%c\n",*p,*++p,*++p,*++p);
}
程序代码:
#include<stdio.h>
#include<string.h>
void fun(char *p,int n);
int main()
{
static char s[]="1234567";
fun(s,strlen(s));
puts(s);
return 0;
}
void fun(char *p,int n)
{
char k,*p1,*p2;
p1=p;
p2=p+n-1;
while(p1<p2)
{
k=*p1++;
*p1=*p2--;
*p2=k;
}
}