Академический Документы
Профессиональный Документы
Культура Документы
PDPU
Memory State
x xptr yptr
50 65524 65520
65524 65520 65516
cout << (unsigned int) yptr; // 65520
cout << (unsigned int) *yptr; // 65524
cout << (unsigned int) &yptr; // 65516
cout << **yptr; // 50
Programs
• Pointer1 (concepts)
• Pointer2 (concepts)
• Pointer3 (modifying add( )
function)
• Pointer4 (swapping of values)
Different Operations on
a Pointer
• Addition of a number to a
pointer.
e.g.
int i = 5, *j , *k;
j = &i;
j++; j += 4;
k = j + 5;
Explanation
10 20 30 40
Address 1000 1004 1008 1012
Different Operations on
a Pointer
• Comparison of two pointer
variables.
• They should be of same type.
e.g.
int arr [ ] = {10,20,30,40};
int * i, * j ;
i = &arr [ 1 ]; j = (arr + 1 );
cout << ((i == j)?"Eq.":"! Eq.“);
!!!!! Words of Caution !!!!!
• Do not attempt