Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Finds the equivalent char to a given char_type.
char narrow(
char_type _Char,
char _Default = '\0'
) const;
Parameters
_Char
The char to convert._Default
The char that you want returned if no equivalent is found.
Return Value
The equivalent char to a given char_type.
Remarks
The member function returns use_facet< ctype<E> >( getloc( ) ). narrow(_Char, _Default).
Example
// 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
Requirements
Header: <ios>
Namespace: std