CPants
Showing posts with label
Pointer
.
Show all posts
Showing posts with label
Pointer
.
Show all posts
Friday, April 5, 2013
The Generic Pointer Type : void *
Any pointer maybe converted to type
void *
without loss of any information. Typical use of
void *
appears in function parameter type definitions ( so the function can receive pointers of arbitrary type: e.g
void *memcpy(void *s, const char *t)
;)
(Think of void pointers as java Object)
Wednesday, April 3, 2013
Pointer Arithmetic
Pointer arithmetic
Can only use addition and subtraction.
Can use to step through an array - use the increment operator to generate the address of the next element.
2 * sizeof(<type-pointed-to>)
of any array of any type, the following is true:
x[i] is equivalent to *(x+i)
Array notes
Array names are considered to be pointers - also constant pointers.
An array name cannot be changed/modified.
x = &y is illegal.
Array name considered to be the address of the 0th element (base address) of the array.
The expression x is equivalent to x[0].
Older Posts
Home
Subscribe to:
Posts (Atom)