.\" ident @(#)wcin.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH wcin 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2wcin\fP \ - Controls input from a stream buffer associated with the object \f2stdin\fP declared in \f2.\fP .SH SYNOPSIS .br #include .br extern wistream wcin; .br wistream wcin; .SH DESCRIPTION The object \f2wcin\fP controls input from a stream buffer associated with the object \f2stdin\fP declared in \f2.\fP By default the standard C and C++ streams are synchronized, but performance improvement can be achieved by using the \f2ios_base\fP member function \f2synch_with_stdio\fP to desynchronize them. After the object \f2wcin\fP is initialized, \f2wcin.tie()\fP returns \f2&wcout\fP, which implies that \f2wcin\fP and \f2wcout\fP are synchronized. \f2wcin\fP uses the locale \f2codecvt\fP facet to convert the tiny characters extracted from \f2stdin\fP to the wide characters stored in the \f2wcin\fP buffer. .SH EXAMPLE .br // .br // wcin example #1 .br // .br #include .br .br void main ( ) .br { .RE .RS 1 using namespace std; .RE .RS 0 .RE .RS 1 int i; .br float f; .br wchar_t c; .RE .RS 0 .RE .RS 2 //read an integer, a float and a wide character from stdin .RE .RS 1 wcin >> i >> f >> c; .RE .RS 0 .RE .RS 2 // output i, f and c to stdout .RE .RS 1 wcout << i << endl << f << endl << c << endl; .RE .RS 0 } .br .br // .br // wcin example #2 .br // .br #include .br .br void main ( ) .br { .RE .RS 1 using namespace std; .RE .RS 0 .RE .RS 1 wchar_t p[50]; .RE .RS 0 .RE .RS 2 // remove all the white spaces .RE .RS 1 wcin >> ws; .RE .RS 0 .RE .RS 2 // read characters from stdin until a newline .br // or 49 characters have been read .RE .RS 1 wcin.getline(p,50); .RE .RS 0 .RE .RS 2 // output the result to stdout .RE .RS 1 wcout << p; .RE .RS 0 } When inputting \f2" Grendel the monster" (newline) \fPin the previous test, the output is: \f2"Grendel the monster"\fP. The manipulator \f2ws\fP removes spaces. .SH SEE ALSO basic_istream(3C++), basic_iostream(3C++), basic_filebuf(3C++), cin(3C++), cout(3C++), cerr(3C++), clog(3C++), wcout(3C++), wcerr(3C++), wclog(3C++), ios_base(3C++), basic_ios(3C++) Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Section 27.3.2 .SH STANDARDS CONFORMANCE ANSI X3J16/ISO WG21 Joint C++ Committee