C++ Pointers
C++ Pointers
*p = 101;
You can verbalize this assignment like this:
“At the location pointed to by p, assign
the value 101.”
increment or decrement:
(*p)++;
(*p)--;
Pointer Pointer
Arithmetic Comparisons
• ++ • ==
•––
•<
• +
• –.
•>
Pointers and Arrays
char str[80];
char *p1;
p1 = str;
• str is an array of 80 characters
• p1 is a character pointer
• p1 is assigned the address of the first element
in the str array. (p1 will point to str[0]).
• For example, if you want to access the fifth
element in str, you can use:
str[4]
or
*(p1+4)