Sort of. Like you said, pointers are often used to pass variables to functions, if the variable is large (a struct, class, array, etc), or if the variable is to be modified in the function. However, it is useful for far more than that. For example, if you had an array of characters, and wanted to search them for a particular letter:<br>[fixed]<br>char szMyString[]="This is my test string!";<br><br>//Find the first occurance of 'e', 'y' or 'r'.<br><br>char *pC=szMyString;<br>//pC now points to the first char in the string<br>while (*pC)<br> if (*pC=='e'||*pC=='y'||*pC=='r') break;<br> else pC++; //Jump to the next char<br>[/fixed]<br>That could be done with the array operator [], but what I have above is the most effecient. Each time you access as an array (pzString[ i ]), math has to be performed to offset by the array index and dereference that value. So above you can see that I only perform math once each iteration (pC++), where if I used an array math would have to be performed 4 times each iteration (once for each comparison, plus you'd have to increment your index).<br>Also, any program that deals with non-trivial amounts of information has to use the heap (as opposed to the stack). The Stack is a chunk of memory every program is given up front to run in. All variables declared in the program (such as szMyString and pC above) are given a chunk of the heap to store their data. One of the problems with the stack is you have to know up-front when you build the program exactly how large each variable will be (this concerns arrays particularly). So what if we need to get ahold of varying amounts of memory at runtime? You allocate it off the Heap. In C++ you can simply use the
new operator:<br>[fixed]<br>//I need "i" characters allocated for a string:<br><br>char *pszString=new char[ i ];<br><br>//See if we got what we wanted<br>//(otherwise we're out of RAM)<br>if (!pszString) return;<br><br>//Do something with my string<br>strcpy(pszString, pszSomeOtherString);<br><br>//Now's the important part, we have to free<br>//the memory we allocated, otherwise we created<br>//a memory leak, and we'll run out eventually.<br>delete []pszString;<br>[/fixed]<br><br>The new and delete functions are specific to C++. In C you would use malloc / free or similar. Also note that I placed two brackets after delete. That tells delete that it is to delete an array. In this case the brackets aren't actually necessary, because what we are deleting is not an array of C++ Classes. It is good practice to use those brackets any time you delete an array so you don't forget when it does matter.<br>I didn't mean to say that much, but oh well.

<br><br>Dan East