Name
wcsdup - duplicate a wide-character string
Library
libc.lib
Synopsis
|
wchar_t
wcsdup (const wchar_t *wcs);
|
Return values
The
wcsdup
function returns a pointer to the new wide-character string, or NULL if sufficient memory was not available.
Detailed description
The
wcsdup()
function allocates sufficient memory for a
copy of the wide-string
wcs
, does the copy,
and returns a pointer to it. The pointer may
subsequently be used as an argument to the function
free.
If insufficient memory is available, NULL is returned and errno is set to
ENOMEM.
Examples
#include <wchar.h>
/* Illustrates how to use wcsdup API */
int example_wcsdup(void)
{
/* input string for which length has to be found */
wchar_t *srcws=L"testwcsdup";
wchar_t *destws = NULL;
/* invoke the API wcsdup to duplicate the string */
destws = wcsdup(srcws);
/* return no error if src str and dest str are equal else return an error */
if(!(wcscmp(srcws,destws)))
{
free(destws);
return 1;
}
else
{
free(destws);
return -1;
}
}
See also
strdup
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|