std::wcsncpy
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <cwchar> 中定义
|
||
wchar_t *wcsncpy( wchar_t *dest, const wchar_t *src, std::size_t count ); |
||
。
count
字符宽字符串的副本src
(包括终止空宽字符)宽字符数组指出,dest
. 原文:
Copies at most
count
characters of the wide string pointed to by src
(including the terminating null wide character) to wide character array pointed to by dest
. 。
count
达到之前的整个字符串src
被复制,宽字符数组是不是空终止原文:
If
count
is reached before the entire string src
was copied, the resulting wide character array is not null-terminated.。之后,如果从
src
复制终止空宽字符,count
还没有达到,额外的空宽字符写入dest
,直到共count
字符已被写入.原文:
If, after copying the terminating null wide character from
src
, count
is not reached, additional null wide characters are written to dest
until the total of count
characters have been written.。如果字符串重叠,该行为是未定义.
原文:
If the strings overlap, the behavior is undefined.
目录 |
[编辑] 。参数。
dest | - | 。指针的宽字符数组复制到。
原文: pointer to the wide character array to copy to |
src | - | 。指针指向宽字符串复制。
原文: pointer to the wide string to copy from |
count | - | 。宽字符复制的最大数量。
原文: maximum number of wide characters to copy |
===。
返回值。===
dest
[编辑] 。注释。
。在典型的使用中,
count
是目标数组的大小.原文:
In typical usage,
count
is the size of the destination array.[编辑] 。为例。
#include <iostream> #include <cwchar> int main() { wchar_t src[] = L"hi"; wchar_t dest[6] = {L'a', L'b', L'c', L'd', L'e', L'f'};; std::wcsncpy(dest, src, 5); // this will copy hi and repeat \0 three times std::wcout << "The contents of dest are: "; for(wchar_t c : dest) { if(c) std::wcout << c << ' '; else std::wcout << "\\0" << ' '; } std::wcout << '\n'; }
输出:
The contents of dest are: h i \0 \0 \0 f
[编辑] 。另请参阅。
一个宽字符串复制到另一个地方 (函数) | |
复制宽字符两个非重叠的阵列之间的一定量的 原文: copies a certain amount of wide characters between two non-overlapping arrays (函数) | |
C documentation for wcsncpy
|