Home > Back-end >  Introduction to C Pointers and arrays
Introduction to C Pointers and arrays

Time:10-11

Double sz [5]={98,87,65,43,76};
Ptr1, double * * ptr2 will;
Ptr1=& amp; Sz.

for(int i=0; i<5; I++) {
Printf (" % 2 lf \ n ", * ptr1 + +);// * ptr1 + + how to understand?
}


If the above code, * ptr1 + + how to understand?

CodePudding user response:

To see whether the priority that * and + + whose priority is high, it is suggested that the building Lord their check,

The expression of the associativity is * (ptr1 + +); After the first reference on the pointer,

CodePudding user response:

Reference value of the pointer, then the pointer + 1, pointing to the sz [1]

CodePudding user response:

Ptr1=& amp; Sz.
This is wrong, ptr1 type is double *, & amp; Sz type is double [5] (*)

* ptr1 + +
Priority is higher than * + +, + + first, plus a one-time 5 * sizeof (double) bytes, the back to sz array an element of solve until the next element address references can't print directly after the reference is an array

CodePudding user response:

The equivalent of
 
Printf (" % 2 lf \ n ", * ptr1);
Ptr1 + +;

The reason is the priority of the right combination operator + + operator below Pointers *
The parentheses can improve right + + operator

CodePudding user response:

reference 4 floor u012538549 response:
ptr1=& amp; Sz.
This is wrong, ptr1 type is double *, & amp; Sz type is double [5] (*)

* ptr1 + +
Priority is higher than * + +, + + first, plus a one-time 5 * sizeof (double) bytes, the back to sz array an element of the next element address after quote have no direct print solution reference is an array


Before a wrong explanation
* ptr1 + +
+ + priority is higher than after * is successively + +, and solutions for reference, the new value + +, but use the expression or the value of the old * remove references is an array, not directly print
After + + one-time added 5 * sizeof (double) bytes, the back to sz array an element of the next element address

CodePudding user response:

reference 4 floor u012538549 response:
ptr1=& amp; Sz.
This is wrong, ptr1 type is double *, & amp; Sz type is double [5] (*)

* ptr1 + +
Priority is higher than * + +, + + first, plus a one-time 5 * sizeof (double) bytes, the back to sz array an element of the next element address after quote have no direct print solution reference is an array

As said on the fourth floor, you simply compile it by not ah

CodePudding user response:

reference 7 building about 0318 reply:
Quote: refer to 4th floor u012538549 response:

Ptr1=& amp; Sz.
This is wrong, ptr1 type is double *, & amp; Sz type is double [5] (*)

* ptr1 + +
Priority is higher than * + +, + + first, plus a one-time 5 * sizeof (double) bytes, the back to sz array an element of the next element address after quote have no direct print solution reference is an array

As said on the fourth floor, you simply compile it by not



You can compile

CodePudding user response:

refer to the eighth floor Big_Carp response:
Quote: refer to 7th floor about 0318 reply:

Quote: refer to 4th floor u012538549 response:

Ptr1=& amp; Sz.
This is wrong, ptr1 type is double *, & amp; Sz type is double [5] (*)

* ptr1 + +
Priority is higher than * + +, + + first, plus a one-time 5 * sizeof (double) bytes, the back to sz array an element of the next element address after quote have no direct print solution reference is an array

As said on the fourth floor, you simply compile it by not



You can compile


Children throw your things away, please change the things to learn what junk software it can compile do something normal to study this type incompatible can also be compiled with you throw out

CodePudding user response:

Ptr1=& amp; Sz.
Oh this is a double (*) [5] casts for double * although incompatible but can convert some system will warn some complains
That's no problem * ptr1 + + + + reconciliation after is the primary pointer reference

CodePudding user response:

The
references to the tenth floor u012538549 response:
ptr1=& amp; Sz.
Oh this is a double (*) [5] casts for double * although incompatible but can convert some system will warn some complains
That's no problem * ptr1 + + + + reconciliation after is the primary pointer reference


Codeblocks sucks? I see a lot of people are in use!

CodePudding user response:

Never used,

Learning C language is the best in the Linux environment

Work in basic it is compile environment is not the same as in the LINUX environment will produce different compile results and understand the

If you write

Ptr1=& amp; Sz.//type inconsistent assignment see you the next print you meant ptr1=sz, because sz and correctly & amp; Sz type, but both of them is the same address values, ptr1=& amp; Sz on the right side of the first to get the right value is the address of sz, ptr1=& amp; Sz type on both sides, need to be assigned to a double * type ptr1, then put the address values cast to ptr1 type is double *
for(int i=0; i<5; I++) {
Printf (" % 2 lf \ n ", * ptr1 + +);//* ptr1 + + how to understand?
}

CodePudding user response:

The
refer to 12 floor u012538549 reply:

On the one hand, some students learn c may be a course of the school, it doesn't matter with future employment;
On the other hand, if just learning in the Linux environment, are still a little difficult, don't have to,
Codeblock although not how to use in real production environment, but can still study,
I just download the proper version, don't be too hard on yourself at the beginning, step-by-step=& gt; Impassable,

CodePudding user response:

references about 0318 13 floor response:
Quote: refer to 12 floor u012538549 reply:

On the one hand, some students learn c may be a course of the school, it doesn't matter with future employment;
On the other hand, if just learning in the Linux environment, are still a little difficult, don't have to,
Codeblock although not how to use in real production environment, but can still study,
I just download the proper version, don't be too hard on yourself at the beginning, step-by-step=& gt; Impassable,

Is strict to yourself with learning software of the time it is better to learn how to make Linux environment of learning more accurate an abnormal software learning error will hurt yourself

CodePudding user response:

+ + priority although above *, + + belongs to the right combination type, so values first, and then address plus one, pointing to an array element

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related