这个 vwprintf() C++中的函数用于将格式化的宽字符串写入 斯特杜特 。它将格式化数据从变量参数列表打印到标准输出。在内部,该函数从 阿格 犹如 瓦乌阿格 是用在上面的,因此 阿格 很可能被电话改变了。宽字符串格式可能包含以开头的格式说明符 % 被作为列表传递的变量值替换 vlist . 它在头文件中定义
null
int vwprintf( const wchar_t* format, va_list vlist )
参数: 该函数接受四个强制参数,如下所述:
- 格式: 指定指向写入标准输出的以null结尾的宽字符串的指针
- arg: 指定一个值,该值标识用初始化的变量参数列表 开始
返回值: 该函数返回两个值,如下所示:
- 成功时,返回写入的字符总数。
- 如果发生错误,则返回负数。
以下程序说明了上述功能: 项目1:
// C++ program to illustrate the // vwprintf() function // for some english letter #include <bits/stdc++.h> using namespace std; // function to print formatted // data from variable argument list to stdout void write( const wchar_t * format, ...) { // hold the variable argument va_list arg; // A function that invokes va_start // shall also invoke va_end before it returns. va_start (arg, format); vwprintf(format, arg); va_end (arg); } // Driver code int main() { setlocale (LC_ALL, "en_US.UTF-8" ); wchar_t buffer[5][10] = { L "First" , L "Second" , L "Third" , L "Fourth" , L "Fifth" }; int k = 0; // print letters by calling write function wprintf(L "Some English Letters" ); for ( wchar_t i = L 'A' ; i <= L 'E' ; i++) { write(L "%ls : %lc" , buffer[k], i); k++; } return 0; } |
输出:
Some English Letters First : A Second : B Third : C Fourth : D Fifth : E
// C++ program to illustrate the // vwprintf() function // for some Latin letters #include <bits/stdc++.h> using namespace std; // function to print formatted // data from variable argument list to stdout void write( const wchar_t * format, ...) { // hold the variable argument va_list arg; // A function that invokes va_start // shall also invoke va_end before it returns. va_start (arg, format); vwprintf(format, arg); va_end (arg); } // Driver code int main() { setlocale (LC_ALL, "en_US.UTF-8" ); wchar_t buffer[5][10] = { L "First" , L "Second" , L "Third" , L "Fourth" , L "Fifth" }; int k = 0; // print letters by calling write function wprintf(L "Some Latin Letters" ); for ( wchar_t i = L 'u0021' ; i <= L 'u0025' ; i++) { write(L "%ls : %lc" , buffer[k], i); k++; } return 0; } |
输出:
Some Latin Letters First : ! Second : " Third : # Fourth : $ Fifth : %
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END