View Single Post
Old 01-18-2004, 11:46 AM   #4
KaVir
Legend
 
KaVir's Avatar
 
Join Date: Apr 2002
Name: Richard
Home MUD: God Wars II
Posts: 2,052
KaVir will become famous soon enoughKaVir will become famous soon enough
Yes, that is exactly right. The reference solution (for C++ only) would look exactly the same as your first example, except that the function argument "char *target" would be written "char *&target".

Note that in addition to dealing with a NULL 'string' argument, there are two other problems which you can't cater for - an uninitialised 'target', or a 'target' which points to memory stored somewhere other than on the heap. These are points to be kept in mind, as they could easily be done by mistake.
KaVir is offline   Reply With Quote