12-04-2012, 02:25 PM
C++ Pointers and Strings
pointers.ppt (Size: 76 KB / Downloads: 40)
Pointers
A pointer is a variable that holds the address of something else.
Assigning a value to a dereferenced pointer
A pointer must have a value before you can dereference it (follow the pointer).
Pointer Parameters
Pointers are passed by value (the value of a pointer is the address it holds).
If we change what the pointer points to the caller will see the change.
If we change the pointer itself, the caller won't see the change (we get a copy of the pointer)
String Manipulation Functions
C++ includes a library of string handling functions:
char * strcpy(char *dst, const char *src)
char * strcat(char *dst, const char *src)
Exercises (for those so inclined)
Write strcpy
Write a function that compares 2 strings and returns true if they are the same string, false if they are not.
Write a function that removes all spaces from a string.