Man, pointers keep bothering me. I thought I understood the concept. (Basically, you should use * ptr when you want to manipulate the actual memory stored in the location pointed to by ptr. You just use ptr if you want to move this pointer by doing things like ptr ++ or ptr--.) So if so, if you use an asterisk to manage the files that the pointer points to, how it works:
char *MallocAndCopy( char *line ) {
char *pointer;
if ( (pointer = malloc( strlen(line)+1 )) == NULL ) {
printf( "Out of memory!!! Goodbye!\n" );
exit( 0 );
}
strcpy( pointer, line );
return pointer;
}
malloc returns a pointer, so I understand why the "pointer" in the if condition does not use an asterisk. However, in the strcpy function, it sends the contents of the string to the contents of the pointer. Must not be:
strcpy( *pointer, *line);
????? , strcpy?