#include<stdio.h> intmain(){foo();// foo() is called before its declaration/definition
}intfoo(){printf("Hello");return0;}
普通指针指向常量变量
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<stdio.h> intmain(void){intconstj=20;/* The below assignment is invalid in C++, results in error
In C, the compiler *may* throw a warning, but casting is
implicitly allowed */int*ptr=&j;// A normal pointer points to const
printf("*ptr: %d\n",*ptr);return0;}
空指针赋值给其他指针
1
2
3
4
5
6
7
#includeint main(){voidvptr;intiptr=vptr;// In C++, it must be replaced with int iptr = (int )vptr;
return0;}