pointers_more - Addressing A Direct Addressing A = 10 100...

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

View Full Document Right Arrow Icon
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

This note was uploaded on 04/30/2008 for the course C CMPE 150 taught by Professor Tuna during the Spring '08 term at Boğaziçi University.

Ask a homework question - tutors are online