这个 wcsncat() 函数附加 来源 到 目的地 ,包括一个以空字符结尾的字符。如果字符串的长度 来源 不到 号码 。则仅复制终止空字符之前的内容。
null
语法:
wchar_t* wcsncat (wchar_t* destination, const wchar_t* source, size_t num)
参数: 该函数接受三个强制性参数,如下所述:
- 目的地: 指定指向目标数组的指针
- 资料来源: 指定要添加到目标的字符串
- 号码: 指定要添加的最大字符数
返回值: 函数返回 目的地 .
以下程序说明了上述功能:
项目1:
// C++ program to illustrate // wcsncat() function #include <bits/stdc++.h> using namespace std; int main() { // maximum length of the destination string wchar_t destination[20]; // maximum length of the source string wchar_t source[20]; // initialize the destination string wcscpy(destination, L "Geekforgeeks " ); // initialize the source string wcscpy(source, L "is the best" ); // initialize the length of // the resulted string you want wcsncat(destination, source, 20); wprintf(L "%ls" , destination); return 0; } |
输出:
Geekforgeeks is the best
项目2:
// C++ program to illustrate // wcsncat() function #include <bits/stdc++.h> using namespace std; int main() { // maximum length of the destination string wchar_t destination[40]; // maximum length of the source string wchar_t source[40]; // initialize the destination string wcscpy(destination, L "only some of the " ); // initialize the source string wcscpy(source, L "letters will be copied" ); // initialize the length of // the resulted string you want wcsncat(destination, source, 20); wprintf(L "%ls" , destination); return 0; } |
输出:
only some of the letters will be copi
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END