[C/C++] _strdup

CS/C/C++ 2009. 8. 14. 00:27
참조 : MSDN

char *_strdup(const char *strSource);
wchar_t *_wcsdup(const wchar_t *strSource);
unsigned char *_mbsdup(const unsigned char *strSource);

Return Value
Each of these functions returns a pointer to the storage location for the copied string or NULL if storage cannot be allocated.

Remarks
The _strdup function calls malloc to allocate storage space for a copy of strSource and then copies strSource to the allocated space.
Because _strdup calls malloc to allocate storage space for the copy of strSource, it is good practice always to release this memory by calling the free routine on the pointer returned by the call to _strdup.
: