Example one: the implementation of character and integer variables
#include <stdio.h>intMain () {intc1,c2; CharC3; C1='a'-'A'; C2='b'-'B'; C3='C'- +; printf ("C1 is%d and C2 are%d\n", C1,C2); printf ("C3 is%d and%c\n", C3,C3); //characters exist in memory in ASCII code, a is 65, etc.//character variables can be calculated with integer variables }
The result is:
32 32
C
The string constant is "" inside the
The character constant is "inside the
Example two:
" stdio.h " int Main () { char A, a=n, b=98; printf (" %c%c\n", A, b); printf ("%d%d"
Ab
9798
-------------------------------
Why do you want to add a ' \o ' to the end of a string constant because the string is stored in ASCII and has an end flag bit. It is hard to tell how much space the string occupies in memory.
Example three: pointer array and level two pointer "Linux C programming page 84th"
#include"stdio.h"intMain () {inta[5]={1,3,5,7,9 }; int*p[5],i; int**pp=p;//equivalent to int a=12;int *b=&a;int **c=&b; The last one here for(i=0;i<5; i++) P[i]=&A[i]; for(i=0;i<5; i++) printf ("%d\n",*P[i]); for(i=0;i<5; i++,pp++) printf ("%d",**pp);}
Example four: pointer and array relationships. Classic examples
#include"stdio.h"intMain () {//Classic example Linux C program on page 85th inta[2][5]={1,3,5,7,9,2,4,6,8,Ten}; int(*p) [5],i;//Int (*p) [5] means p is a pointer to a one-dimensional pointer containing 5 elements, and P is the first address of a one-dimensional arrayp=A; for(i=0;i<5; i++) printf ("%d",(*p) [i]); printf ("\ n"); P++;//p plus 1, pointing to the second row of the two-dimensional array a for(i=0;i<5; i++) printf ("%d",(*p) [i]); printf ("\ n"); return 0; }
Examples of Linux C programming examples