Name
wcpncpy - copy a fixed-size string of wide characters, returning a pointer to its end
Library
libc.lib
Synopsis
|
wchar_t *
wcpncpy (wchar_t *dest , const wchar_t *src, size_t n);
|
Return values
The
wcpncpy()
function returns a pointer to the wide character one past
the last non-null wide character written.
Detailed description
The
wcpncpy()
function
copies at most
n
wide characters from the wide-character string
src
, including the terminating L’\0’ character, to
dest
.Exactly
n
wide characters are written at
dest
.If the length
wcslen(src)
is lesser than
n
, the remaining wide characters in the array dest are filled
with L’\0’ characters. If the length
wcslen(src)
is greater than or equal to
n
, the string dest will not be L’\0’
terminated.
Examples
#include <stdlib.h>
#include <wchar.h>
/* Illustrates how to use wcpncpy API */
int example_wcpncpy(void)
{
/* input string for which length to be found */
wchar_t *src = L"testcase";
wchar_t *dest = NULL;
wchar_t *destEndPtr = NULL;
/* allocate memory for the destination string */
dest = (wchar_t *)malloc((wcslen(src)+1)*sizeof(wchar_t));
/* perform the operation */
if(dest != NULL)
destEndPtr = (wchar_t *)wcpncpy(dest,src,wcslen(src)+1);
else
return -1;
/* checking for error */
if(!wcscmp(dest,src))
{
wprintf(L"wcpncpy succeeded\n");
free(dest);
return 0;
}
else
{
wprintf(L"wcpncpy failed!!\n");
free(dest);
return -1;
}
}
See also
wcpcpy
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|