When I was reviewing the soft exam, I was going to extend it and thoroughly split the array name and pointer.
As a result, the code I wrote completely fainted myself...
Code:
- # Include "stdio. H"
- Int fun1 (int *)
- {
- Int * P = (int *) (& A + 1 );
- Printf ("% d/N", * );
- Printf ("% d/N", );
- Printf ("% d/N", & );
- Printf ("% d/N", & A + 1 );
- Printf ("% d/N", P [-1]);
- Return 0;
- }
- Int fun2 (INT **)
- {
- Int * P = (int *) (a + 1 );
- Printf ("% d/N", ** );
- Printf ("% d/N", * );
- Printf ("% d/N", );
- Printf ("% d/N", A + 1 );
- Printf ("% d/N", P [-1]);
- Return 0;
- }
- Int fun3 (int *)
- {
- Int * P = (int *) (INT (*) [5]) (a) + 1 );
- Printf ("% d/N", * );
- Printf ("% d/N", );
- Printf ("% d/N", & );
- Printf ("% d/N", & A + 1 );
- Printf ("% d/N", P [-1]);
- Return 0;
- }
- Int main ()
- {
- Int A [5] = {1, 2, 3, 4, 5 };
- Int * P = (int *) (& A + 1 );
- Printf ("% d/N", * );
- Printf ("% d/N", );
- Printf ("% d/N", & );
- Printf ("% d/N", & A + 1 );
- Printf ("% d/N", P [-1]);
- Fun1 ();
- Fun3 ();
- Fun3 ();
- Fun2 (& );
- Return 0;
- }
The output of two fun3 (a) is different...
And fun2 should not output 5 at all.
And if the function is executed in this Order
Fun1 ();
Fun2 (& );
Fun3 ();
Fun3 does not work !!! Khan... can you help me?