pointers_more

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Addressing A Direct Addressing A = 10 100 10 101 102 103 104 Indirect Addressing Pointer If we can't use the variable A can' We copy the address of A in a variable P called Pointer We access to the value of A through P A P 10 100 101 102 103 101 104 What do we need to use pointers &: To get a variable address *: To access to the value stored in the address pointed P A 10 B 50 P = &A; B = *P; *P = 20; P A 20 B 10 Examples Having P = &X, are the following expressions true? Y = *P +1 *P = *P + 1 P +=2 *p +=2 (P)++ Y = X +1 X = X +1 X += 2 X += 2 X++ Init. P1=&A; P2=&C P2=&C *P1=(*P2)++; P1=P2; P2=&B; *P1-=*P2; *P1++*P2; *P1*=*P2; A=++*P2**P1; P1=&A; main( ) { int A = 1, B = 2, C = 3 , *P1, *P2; P1=&A; P2=&C; *P1=(*P2)++; P1=P2; P2=&B; *P1-=*P2; ++*P2; *P1*=*P2; A=++*P2**P1; P1=&A; return 0; A B C P1 1 2 3 / &A 3 4 &C P2 / / &C &B 2 3 6 24 4 &A } ...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern