Home > Back-end >  Small white online for advice about pointer practice, C C. Everybody a great god help have a look.
Small white online for advice about pointer practice, C C. Everybody a great god help have a look.

Time:09-21

# include & lt; Stdio. H> Int main (void) {int a [6]=

{6};//definition contains six integer element of array a int

I=0, j=0; Int aa [3] and [2]={{2, 3}, {4, 5}, {9}};//define a 2

Aa, 3 d array row 2 column for (I=0; I<6; I++)

Printf (" a [% d]==% d, "and I, a [I]);//the subscript access method output element value;

Putchar (" \ n "); for( i=0; I<6; I++) printf (" * (a +

==% d, % d) ", I, * (a + I));//pointer to access method output element value

Putchar (" \ n ");//output an empty

//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int

* p=NULL;//define a pointer, used for bearing array

Aa [3] a [6] and [2] p=a;//pointer p, to traverse the output array a and

Two-dimensional array element value of aa and address

Values,//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int (* pp) [2]=

{aa [0], [1], aa aa [2]}.//pp with Pointers to traverse the two-dimensional array output

Aa element value and address values,//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int

* * pt=NULL;//pointer pt to traverse the two-dimensional array output of aa yuan

Element value and address,//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int

A1=100, b=200; Const int * p1=& amp; A1. Int * const

The p2=& amp; A1. Const int * const p3=& amp; A1.//the above three words

, (1) try to by a pointer (p1, p2, p3) indirect access to modify a1 (*)

Value is 50, (2) modify the pointer pointing to the variable b, debugger, see

What operation is feasible and what not,}

CodePudding user response:

Can arrange a minute version, zha this code to let people see

CodePudding user response:

Debug it and see

CodePudding user response:

Edit a line above, the fifth is to add the code on the right

CodePudding user response:

Has been redistributed

CodePudding user response:

see not bottom go to, see the last edition

CodePudding user response:

The
reference 5 floor mountain rain, response:
see not bottom go to, see the last edition

# include & lt; Stdio. H>
Int main (void)
{
Int a [6]={6};
//definition contains six integer element of array a
Int I=0, j=0;
Int aa [3] and [2]={{2, 3}, {4, 5}, {9}};
//define a 2 d array aa, 3 row 2 column
For (I=0; I<6; I++)
Printf (" a [% d]==% d, "and I, a [I]);
//the subscript access method output element value;
Putchar (" \ n ");
for( i=0; I<6; I++)
Printf (" * (a + % d)==% d ", I, * (a + I));
//pointer to access method output element value
Putchar (" \ n ");
//output a blank line
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int * p=NULL;
//define a pointer, used for bearing the array a aa [3] and [6] [2] p=a;
Pointer p,//used to traverse the output array a and aa two-dimensional array element value and address values,
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int (* pp) [2]={aa [0], [1], aa aa [2]}.
//pp with Pointers to traverse the output two-dimensional array element value of aa and address values,
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int * * pt=NULL;
//pt with Pointers to traverse the output two-dimensional array element value of aa and address values,
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int a1=100, b=200;
Const int * p1=& amp; A1.
Int * const p2=& amp; A1.
Const int * const p3=& amp; A1.
//the three statements above, (1) try to by a pointer (p1, p2, p3) indirect access (*) modify a1 has a value of 50, (2) modify the pointer pointing to the variable b, debugger, see what is feasible and what not,
}

CodePudding user response:

reference 1st floor CHXCHXKKK response:
can row a minute version, this code lets a person zha?

# include & lt; Stdio. H>
Int main (void)
{
Int a [6]={6};
//definition contains six integer element of array a
Int I=0, j=0;
Int aa [3] and [2]={{2, 3}, {4, 5}, {9}};
//define a 2 d array aa, 3 row 2 column
For (I=0; I<6; I++)
Printf (" a [% d]==% d, "and I, a [I]);
//the subscript access method output element value;
Putchar (" \ n ");
for( i=0; I<6; I++)
Printf (" * (a + % d)==% d ", I, * (a + I));
//pointer to access method output element value
Putchar (" \ n ");
//output a blank line
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int * p=NULL;
//define a pointer, used for bearing the array a aa [3] and [6] [2] p=a;
Pointer p,//used to traverse the output array a and aa two-dimensional array element value and address values,
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int (* pp) [2]={aa [0], [1], aa aa [2]}.
//pp with Pointers to traverse the output two-dimensional array element value of aa and address values,
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int * * pt=NULL;
//pt with Pointers to traverse the output two-dimensional array element value of aa and address values,
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- int a1=100, b=200;
Const int * p1=& amp; A1.
Int * const p2=& amp; A1.
Const int * const p3=& amp; A1.
//the three statements above, (1) try to by a pointer (p1, p2, p3) indirect access (*) modify a1 has a value of 50, (2) modify the pointer pointing to the variable b, debugger, see what is feasible and what not,
}
  • Related