| Localization library | |||||||||||||||||||||||||
| Regular expressions library(C++11) | |||||||||||||||||||||||||
| Formatting library(C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Functions | ||||||||||||||||||||||||||
| Character classification | ||||||||||||||||||||||||||
| Character manipulation | ||||||||||||||||||||||||||
| Conversions to numeric formats | ||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||
| String manipulation | ||||||||||||||||||||||||||
| String examination | ||||||||||||||||||||||||||
| Array manipulation | ||||||||||||||||||||||||||
Defined in header <cwchar> | ||
wchar_t* wcsncpy(wchar_t* dest,constwchar_t* src,std::size_t count); | ||
Copies at mostcount characters of the wide string pointed to bysrc (including the terminating null wide character) to wide character array pointed to bydest.
Ifcount is reached before the entire stringsrc was copied, the resulting wide character array is not null-terminated.
If, after copying the terminating null wide character fromsrc,count is not reached, additional null wide characters are written todest until the total ofcount characters have been written.
If the strings overlap, the behavior is undefined.
Contents |
| 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
In typical usage,count is the size of the destination array.
#include <cwchar>#include <iostream> int main(){constwchar_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(constwchar_t c: dest){if(c)std::wcout<< c<<' ';elsestd::wcout<<"\\0"<<' ';}std::wcout<<'\n';}
Output:
The contents of dest are: h i \0 \0 \0 f
| copies one wide string to another (function)[edit] | |
| copies a certain amount of wide characters between two non-overlapping arrays (function)[edit] | |
| copies a certain amount of characters from one string to another (function)[edit] | |
C documentation forwcsncpy | |