Quantcast
Channel: confused about the result?
Viewing all articles
Browse latest Browse all 2

confused about the result?

$
0
0
char str[]="hello people";
char *p=&str[0];
char *tem=&str[1];
printf("p=%p\n",p);
printf("*p=%c\n",*p);

hi,

I'm confused about "%p". I searched about it. it is about a address. Then I tested it with the code below.

       char str[]="hello people";
	char *p=&str[0];
	char *tem=&str[1];
	printf("p=%p\n",p);
	printf("*p=%c\n",*p);++*p++;
	printf("p=%p\n",p);
	printf("*p=%c\n",*p);
	puts(str);
I thought the result of puta(str) is "hfllo people". However, the result is "iello people". Why the result is "iello people" instead of "hfllo people"? Could anyone help me?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images