据我所知,我已在线添加了您问题的答案:
#include<stdio.h>
int main()
{
int x=0,*p=0;
char c = 'A', *ch=0;
x++;
// You have initialized this to 0, so incrementing adds 4 (int pointer)
// Remember, the address '4' means nothing here
p++;
// You have initialized this to 0, so incrementing adds 1 (char pointer)
// Remember, the address '1' means nothing here
ch++;
// You are now printing the values of the pointers itself
// This does not make any sense. If you are using pointers, you would want to know what is being referenced
printf ("%d , %d and %d\n",x,p,ch);
// This will FAIL
// Because, you are now trying to print the data pointed by the pointers
// Note the use of '*'. This is called de-referencing
printf ("%d , %d and %d\n", x, *p, *ch);
// Let p point to x, de-referencing will now work
p = &x;
printf ("%d , %d\n", x, *p); // 1, 1
// Let ch point to c, de-referencing will now work
ch = &c;
printf ("%c , %c\n", c, *ch); // 'A', 'A'
return 0;
}
希望这可以帮助。