.\" ident @(#)cin.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH cin 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2cin\fP \ - Controls input from a stream buffer associated with the object \f2stdin\fP declared in \f2\fP.\f2\fP .SH SYNOPSIS .br #include .br extern istream cin; .br istream cin; .SH DESCRIPTION The object \f2cin\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 you can improve performance by using the \f2ios_base\fP member function \f2synch_with_stdio\fP to desynchronize them. After the object \f2cin\fP is initialized, \f2cin.tie()\fP returns \f2&cout\fP, which implies that \f2cin\fP and \f2cout\fP are synchronized. .SH EXAMPLE .br // .br // cin example #1 .br // .br #include .br .br void main ( ) .br { .RE .RS 1 using namespace std; .RE .RS 3 .RE .RS 1 int i; .br float f; .br char c; .RE .RS 0 .RE .RS 2 //read an integer, a float and a character from stdin .RE .RS 1 cin >> i >> f >> c; .RE .RS 0 .RE .RS 2 // output i, f and c to stdout .RE .RS 1 cout << i << endl << f << endl << c << endl; .RE .RS 0 } .br .br // .br // cin example #2 .br // .br #include .br .br void main ( ) .br { .RE .RS 1 using namespace std; .RE .RS 0 .RE .RS 1 char p[50]; .RE .RS 0 .RE .RS 2 // remove all the white spaces .RE .RS 1 cin >> ws; .RE .RS 0 .RE .RS 2 // read characters from stdin until a newline .br // or 49 characters have been read .RE .RS 1 cin.getline(p,50); .RE .RS 0 .RE .RS 2 // output the result to stdout .RE .RS 1 cout << p; .RE .RS 0 } When inputting \f2" Grendel the monster" (newline)\fP in 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++), cout(3C++), cerr(3C++), clog(3C++), wcin(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.1 .SH STANDARDS CONFORMANCE ANSI X3J16/ISO WG21 Joint C++ Committee