A colleague occasionally sent out an interesting piece of code a few days ago, which has never been seen before. It is a collection. It can be defined in C as follows:
Code:
#include<stdio.h>void function(arg1, arg2)int arg1;int arg2;{ printf("arg1=%d, arg2=%d", arg1, arg2);}int main(){ function(1,2); function(1); function(); return 0;}
---------------------------------------------------------------
Output:
arg1=1, arg2=2
arg1=1, arg2=2
arg1=1, arg2=2
------------------------------------
You can also try to change the function call sequence as follows:
function();
function(1);
function(1,2);
The output is as follows:
arg1=134513424, arg2=134513755
arg1=1, arg2=134513755
Arg1 = 1, arg2 = 2
The reason is not the memory function of the function, but the function is called,
The content on the stack (or General registers) is not changed,
Therefore, the output is the same. Whether the output structure is the same each time,
It is based on the compiler and hardware.
If between the call of function (1) and function,
By calling other functions, you can change the stack or register content,
After this call, the source results will be different.