Mail Archives: djgpp/1998/08/13/19:45:43
John Meyer wrote:
> Okay, could somebody tell me a practical use of pointers once and for all?
> I am banging my head against the monitor trying to figure out what the heck
> pointers are good for.
How about dynamic memory allocation!?:
int *integerPtr = new int[10];
Or, searching for a character in a string:
char *aString = "Hello!";
char *ptr = aString;
while( *ptr ) {
if( *ptr == 'e' )
printf("Found the letter 'e'!\n");
ptr++;
}
I hope this is all you need to keep you from banging your head against
the monitor :)
Regards,
Chris Bill
- Raw text -