Home > Back-end >  C language pointer function problem solving
C language pointer function problem solving

Time:10-04

There is something wrong with this program? What is right,
#include
Int main ()
{int a [5], I, * p;
P=a;/* will to a */array p
Printf (" please enter the five integers: \ n ");
for(i=0; I<5; I++)
The scanf (" % d ", p + I);/* p + I is the ith element address */
Printf (" in the opposite order to the result of the output: \ n ");
P=& amp; A, [2]./* will point to an array element a [2] */p
For (I=4; i>=0; I -)
Printf (" % d ", p [I]);/* equivalent to the printf (" % d ", p [I]); */
return 0;
}

CodePudding user response:

P=& amp; A, [2]./* will point to an array element a [2] */p
For (I=4; i>=0; I -)
Printf (" % d ", p [I]);
At this point p [I] is equivalent to a [2 +] I

According to the loop, the output result is a [6], a [5], a [4], a [3] and [2] a

P=& amp; A, [4].
For (I=0; I<=4; I++)
Printf (" % d ", * p -);
This output in reverse chronological order

CodePudding user response:

Fun
reference 1 floor response:
p=& amp; A, [2]./* will point to an array element a [2] */p
For (I=4; i>=0; I -)
Printf (" % d ", p [I]);
At this point p [I] is equivalent to a [2 +] I

According to the loop, the output result is a [6], a [5], a [4], a [3] and [2] a

P=& amp; A, [4].
For (I=0; I<=4; I++)
Printf (" % d ", * p -);
This reverse output

Thank you
  • Related