They can point to functions so functions can be invoked via the pointer. Very handy. They can point to anything in memory or any type of memory like EMS and XMS. In fact to use XMS you must use a pointer to it's core function to make the API calls. EMS returns the address of the page frame segment so your pointer should point to that to move pages to physical page(s) and thus to logical pages.

Pointers make it easy to associate another class to a class instead of using derived classes. This way it is easier to disassociate an interface element from a class than it would be if you use derived classes. Of course you don't get the benefits of inheritance, etc. Both methods work well in diff situations.

Pointer also allow you to swap very easily. Let's say I have a backbuffer pointer and a screen pointer - one points to offscreen mem and one points to vidram.

You can use pointers, which take a small amount of memory, to manipulate large data stuctures.
For example, if you had a file with 50,000 records, each record 100 kb in size, and wanted to sort it, it would be a laborious operation to sort each separate record. Instead, sort pointers to the records. Quicker, less code, etc.

that's a really good example unregistered... a really good one... and that's a really good point bubba, a really good one... [i've for some reason never had to use either, even if the latter would seem to be more applicable...]

good point drake... which is to say that pointers can allow you to restructure your program execution sequences with minimal change... i'd say that pointer usage is to non-pointer usage like dynamic memory allocation is to static memory allocation... as an analogy...

If you've got a function in which a variable is created, normally this variable would be created in the stack and would be cleared after the function returns the result (or not, if it returns void). When using pointers, the variable would remain intact.

The array is allocated on the stack. The stack is not very large. If you do this, however:

char * x = new char[823]

...then it is allocated on the heap, and that's of just about unlimited size. (I wouldn't recommend allocated anything over what you can hold in physical memory, though).

Try to compile the following program:

Code:

int main()
{
long array[7981237893217983127893];
return 0;
}

When you try to run it, you will get an error.

I figured I'd mention this because it hadn't been mentioned before. However, this is not the biggest reason to understand pointers.

Let's say, for example, that you want to make a simple text-based game where you can walk from room to room, and, when you enter a room, a pre-written description appears on the screen.

You COULD write a billion IF and switch statements. An easier way, however, would be to have a ROOM class/struct with a pointer to a character array (the description of the room) and a pointer to an array of pointers to adjacent rooms. Then you could load "maps" from files!!

I recommend that ou read the tutorial on linked lists here on CProgramming.com to get an idea of how pointers can be useful.