Overloading of functions:
# include <stdio.h>void swap (void) {printf ("Hehe! \ n "); return;} void swap (int i, int j) {printf ("Haha! \ n "); return;} int main (void) {swap (), swap (1, 2),//function with the same name, different number of parameters, and not the same function. int i = 3;printf ("i =%d\n", i);//free (); The free function frees the variable to occupy the memory of printf ("I =%d\n", i); return 0;}
The modulated function modifies the value of the variable in the main function:
# include <stdio.h>void change (int * p) {*p = 10;//equivalent to: i = 10;return;} int main (void) {int i = 3;printf ("before modification: i =%d\n", i); change (&i);//If you want to modify the function, you must send the address. printf ("Modified: i =%d\n", i); return 0;}
Empty pointer null:
# include <stdio.h>int main (void) {int * p;//printf ("%d", *p);//read a piece of space without access and cause the program to crash. int * Q;q = null;printf ("%d", *q); The memory space pointed to by the null pointer is not readable or writable and is directly faulted. return 0;}
Operation of pointer variables:
# include <stdio.h>int main (void) {int i = 3;int j = 5;int A[50];int * p = &i;int * q = &j;q-p;//not in the same storage space Two variables I, J address subtraction meaningless. p = &a[1];q = &a[44];p rintf ("%d\n", q-p); That is, the hexadecimal number is subtracted and then output in decimal. return 0;}
The byte that the pointer variable occupies:
# include <stdio.h>int main (void) {int i = 3;int Len;len = sizeof (char *);//sizeof function, the number of bytes that the return data type occupies. printf ("%d\n", Len); return 0;} /* After many experiments, a pointer variable, regardless of the type of pointer variable, is 4 bytes (32-bit machine). */
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Getting Started with C programming-pointers (bottom)