This documentation is archived and is not being maintained.

basic_ios::narrow 

Finds the equivalent char to a given char_type.


char narrow(
   char_type _Char,
   char _Default = '\0'
);

Parameters

_Char

The char to convert.

_Default

The char that you want returned if no equivalent is found.

The equivalent char to a given char_type.

The member function returns 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;
}

116
test
t

Header: <ios>

Show: