basic_ios::narrow
尋找對等字元為指定 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