Definition of pointer variable
Variable type * variable name;
#include <stdio.h>int main () { // pointer is a function: can access the corresponding storage space according to an address value // int before pointer variable p: Pointer variable p can only point to data of type int int // defines a pointer variable p
int - ; p = &A; //pointer variable p points to variable a pointer variable can only store address
ten; // the * differs from the * when defining a pointer variable, which represents access to the corresponding storage space - ; printf ("%d\n", *p); return 0 ;}
Practice
//modify external variables within a function based on the pointer#include <stdio.h>voidChangeint*p);intMain () {intA =Ten; Change (&a); printf ("a=%d\n", a); return 0;}voidChangeint*p) { *p = -;}
//using pointers to let functions indirectly have multiple return values#include <stdio.h>intMain () {intA = the; intb =Ten; intHe=0, cha=0; Test (A, B,&he,&cha); printf ("and is%d, the difference is%d", He,cha);}voidTestintAintBint(CNint*d) { *c = A +b; *d = Ab;}
C language-06 complex data types-03 pointers