The pointer of the C language has always made a headache. Below is the experience of the pointer collected from the Internet. I forgot who the author is, first posted for your reference:
first question:
Main ()
{
Char * p, * q;
Char str [] = "Hello, World / N";
Q = P = STR;
P ;
Printf (q);
Printf (p);
}
What is the result of running? ____________
Question 2:
Void Fun (Char * STR1, Char * STR2)
{
Static char buffer [21];
STRNCPY (Buffer, STR1, 10);
STRNCAT (Buffer, STR2, 10);
* STR1 = * STR2;
Str1 = buffer;
}
Main ()
{
Char * str1 = "abc / n";
CHAR * STR2 = "BCD / N";
Fun (STR1, STR2);
Printf (STR1);
Printf (STR2);
}
The result of the program is __________________
Three questions:
Main ()
{
Short ar [11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11};
Short * Par = & ar [1];
INT I;
For (i = 0; i <10; i )
{
Printf ("% - 5HD% -5HD% -5HD", Ar [i], par [i], * (ar i));
}
}
The result of the program is __________________
The fourth question:
Main ()
{
Short * p, * q;
Short ar [10] = {0};
P = Q = Ar;
P ;
Printf ("% 5d", P-Q);
Printf ("% 5D", (char *) P - (char *) q);
Printf ("% 5d", SIZEOF (AR) / sizeof (* ar));
}
Suppose SIZEOF (Short) == 2
The result of the program is __________________
The fifth question:
int SUB (int A, int b)
{
Return A-B;
}
Main ()
{
TypedEf Int (INT, INT);
SUB PSUB = SUB;
/ * psub ; * /
Printf ("% D", PSUB (10, (10, 5)));
}
The result of the program is _________________, if the intermediate comment is added, why is compiled?
Chapter 6:
Main ()
{
Char * pstrar [3];
INT I;
For (i = 1; i <3; i )
{
Pstrar [I] = ""
}
STRCPY (Pstrar [1], "Hello");
/ * STRCPY (Pstrar [0], "World"); * /
Printf (pstrar [2]);
}
Suppose the compiler sets the string constant for readiler, then the program results are ____________
Why is it not correct?
Seventh question:
Main ()
{
CHAR * P1, * P2;
{
Char * pchar;
Char charar [] = "Hello, the world";
PCHAR = "Hello, World!";
P1 = pchar;
P2 = charar;
}
Printf (P1);
PRINTF (P2);
Say the mistake of this program?
The eighth question:
Main ()
{
INT I;
Char ** P;
INT MSG [16] = {0x40, 0x41, -1, 0x00, 0x01, -1, 0x12, -1, 0x20, 0x27, 0x41, 0x35, -1, 0x51, 0x12, 0x04};
Char * strar [] = {"Bejing", "Shanghai", "Guangzhou", "Guangdong", "Tokyo", "American"}
Char * (* pstrar) [6];
Pstrar = & strar;
p = strar;
For (i = 0; i <16; i )
{
IF (MSG [i] == -1)
{
PUTCHAR ('');
CONTINUE;
}
ELSE IF (MSG [I] & 0xF0 == 0x40)
{
Putchar (P [MSG [I] >> 4] [MSG [i] & 0x
0F
]);
CONTINUE;
}
Else IF (MSG [I] & 0xF0 == 0x30)
{
Putchar (* (strar [MSG [I] >> 4] (MSG [i] & 0x
0F
))))
CONTINUE;
}
Else
{
Putchar (* (* pstrar) [MSG [I] >> 4] (MSG [i] & 0x
0F
))))
}
}
}
This question is to make a mystery, but if you understand the pointer, it is not difficult to solve.
Excuse me the result of this question ____________________
Ninth question:
Main ()
{
Typedef char CA3 [2] [2] [2];
Typedef ca3 * pca3;
Typedef char CA2 [2] [2];
TypeDef Ca2 * PCA2 [2];
Ca3 Ca3 = {'A', '/ 0', 'B', '/ 0', 'C', '/ 0', 'D', '/ 0'};
PCA3 PCA3 = & CA3;
PCA2 PCA2 = {CA3, CA3 1};
INT i = 0, j = 0;
For (i = 0; i <2; i )
{
Printf ("/ n");
Printf ("% s / n", (char *) PCA3 [0] [i]);
Printf ("% S / N", (* (PCA2 I)) [0] [1]);
For (j = 0; j <2; j )
{
Putchar (* (* (CA3 I) J) [0]);
PUTCHAR ('');
}
}
}
The result of the output is: _____________________
Chain 10:
/ * C questions * /
#include
Class Display
{
PUBLIC:
Virtual int showit (int NUM) {Printf ("% D / N", NUM); RETURN 0;}
INT Showit (Double Num) {Printf ("% LF / N", NUM); RETURN 0;}
}
Class DisplayEx: Public Display
{
PUBLIC:
INT Showit (INT NUM) {Printf ("IT IS INTEGER, VALUE IS% D / N", NUM; RETURN 0;} int showit (const char * str) {Printf ("% s / n", str); Return 0;}
}
int main ()
{
DisplayEx DPEX;
Display * p_base = & DPEX;
P_Base-> Showit (168);
p_base-> showit (1.68);
DPEX.SHOWIT ("Hello, World / N");
DPEX.SHOWIT (1.69);
DPEX.DISPLAY :: Showit (1.69);
Return 0;
}
Please tell the result of its run ___________________
The method of implementing this process in detail the C compiler.