| Graphic Pointing Device |
|
A small graphic that moves around the screen as the user manipulates the mouse (or another pointing device). Depending on its location and the active application, the pointer can assume various shapes, such as an arrowhead, crosshair, or clock. By moving the pointer and pressing mouse buttons, a user can select objects, set the insertion point, and activate windows. Sometimes called the "cursor." See also insertion point. Very simplely, a pointer is a variable that holds a memory address. You declare a pointer by first declaring its type (ie. int, char, short, etc.) and then give its name. A pointer declaration looks just like a regular variable declaration except it has an * in it (ex. int *bob). Pointers are extremely useful in C programming. A good example of where one might want to use a pointer is when there are multiple functions being called by a program it is usually easier and saves memory and processor resources to pass a pointer to a variable rather than the variable itself. Pointers are only as big as the operating system (ie. Windows and Unix are 32 bit operating systems so pointers in Windows and Unix are 32 bits or 4 bytes, in DOS the pointers are 16 bits, a 64 bit OS will have 64 bit pointers, etc.). One common misconception about pointers are that they are the same as arrays. This is not true at all. Arrays can hold integers, character, floating point numbers, etc. but pointers can only hold an address. Pointers can point to an array , but they can't hold the same data as an array. If you place a four letter char string in a pointer, the computer will take the bit sequence that makes up that string, treat it as an address, and attempt to go to that address which will result in a segmentation fault and a core dump. To help understand pointers further go look at my sample C program which explains how each line works and shows what happens in memory. |