The complexity of C language is absolutely unimaginable. For some special reasons, C exists at the same time.
Some tangled features.
The following describes some interesting C languages.Code.
Exp:
Main () {printf (& UNIX ["\ 021% six \ 012 \ 0"], (UNIX) ["have"] + "fun"-0x60 );}
Step 1:
For such code, the first thing to understand is to scale down, as shown below:
Main () {printf (& UNIX ["\ 021% six \ 012 \ 0"], (UNIX) ["have"] + "fun"-0x60 );}
As shown above, it is still hard to understand. We can scale it down:
Main () {printf (& UNIX ["\ 021% six \ 012 \ 0"],/
(UNIX) ["have"] + "fun"-0x60 );}
Step 2:
The scaled-down code and the function prototype of the printf function are as follows:
Size_t printf (const char * format ,...);
We know in the above Code:
Const char * format = & UNIX ["\ 021% six \ 012 \ 0"]
Our first variable parameter is:
Va_list [1] = (UNIX) ["have"] + "fun"-0x60); // simply assume that the variable parameter is an array type, participate in K & R tutorials
Next we will analyze:
Format pointer; in Unix systems, there is a default definition, that is:
# Define UNIX 1
So you can know
* Format = & UNIX ["\ 021% six \ 012 \ 0"] = & "\ 021% six \ 012 \ 0" [1]
= & ("\ 021% six \ 012 \ 0" [1]) // This indicates that the Pointer Points to this place, which is similar to & array [I]
We can see that:
* Format = "% six \ 012 \ 0" = "% six \ 021 \ 0"
Step 3:
Analysis (UNIX) ["have"] + "fun"-0x60:
(UNIX) ["have"] + "fun"-0x60 = "have" [UNIX] + "fun"-0x60
= "Have" [1] + "fun"-0x60
= 'A' + "fun"-0x60
= 97 + "fun"-0x60
= 97 + "fun"-96
= "Fun" + 1
Step 4: Merge
Merge the preceding * Format and... variable parameters and output them using the printf function:
Printf ("% six \ 021 \ 0", "fun" + 1 );
Here we use:
% S outputs "fun" + 1 as the address string, so the output is: UN
While
Output IX \ 021 \ 0 in format
Therefore, the output after merging is:
UNIX
I found that many teaching materials in China have not thoroughly explained many of the knowledge points used here, including, of course, our university
Many teachers recommended Tan's tutorials in it. In order to better understand C's suggestion, I suggest reading books written by foreigners. After all, C was invented by foreigners,
In addition, in the process of translation, it is difficult to find completely consistent Chinese characters to represent English words.
This means that English is more suitable for descriptive technology than Chinese. // If not, you can think about it.
I will not talk about it much. In view of the limited level of C language, the above analysis will inevitably lead to errors. You are welcome to bend over and look for bricks,