Directly run the Code:
(1). Exchange the values of Two Parameters
# Include <stdio. h>
Int main ()
{
Int A = 10, B = 5;
A ^ = B ^ = a ^ = B;
Printf ("A = % d, B = % d \ n", a, B );
Return 0;
}
// Output result a = 5, B = 10;
(2). recursively implement string reverse output # include <stdio. h>
# Include <stdio. h>
Void fun (char * Str)
{
If (* (STR + 1 )){
Fun (STR );
Printf ("% C", * Str );
}
}
Int main ()
{
Char * P = "Hello World ";
Fun (P );
Return 0;
}
This is the reverse string Output Using recursive functions.
3. array and pointer
# Include <stdio. h>
# Define M 2
Int main ()
{
Printf ("% s \ n", & M ["\ 012asd"]);
Return 0;
}
The output is "SD ";
1. "\ 012asd" is a pointer. 2.a[ 5] is equivalent to 5 [A]. 3. If we regard "\ 012asd" as a pointer P, we can
& M ["\ 012asd"] is regarded as an & P [2], directly skipping the first character '\ 012' and the second character 'a ', therefore, "SD" should be output ".
4. Do ...... while ()
# Include <stdio. h>
# Define fun (a, B) do {printf ("% d \ n", a); A ++} while (B>)
Int main ()
{
Int x = 2, y = 10;
Fun (x, y); // you can try to change do... while () to while () or to a for () loop. And you will find out what's new.
Return 0;
}
You can try to change do... while () to while () or to a for () loop. And you will find out what's new.
C's skill