查找等效的 char 到给定的 char_type。
char narrow(
char_type _Char,
char _Default = '\0'
) const;
参数
_Char
要转换的 char。_Default
所需的 char 返回,则等效找到。
返回值
对给定 char_type的等效的 char。
备注
成员函数返回 use_facet< ctype<E> >( getloc) ()。 narrow(_Char, _Default).
示例
// basic_ios_narrow.cpp
// compile with: /EHsc
#include <ios>
#include <iostream>
#include <wchar.h>
int main( )
{
using namespace std;
wchar_t *x = L"test";
char y[10];
cout << x[0] << endl;
wcout << x << endl;
y[0] = wcout.narrow( x[0] );
cout << y[0] << endl;
}
Output
116
test
t
要求
页眉: <ios>
命名空间: std