Home

CIN

Cin is most commonly encountered as the standard input stream in the C++ programming language, written as cin in code. In C++, cin is part of the iostream library and is typically referred to as std::cin. It provides access to the program’s standard input device, usually the keyboard, and is used with the extraction operator (>>) to read formatted values into variables.

Usage is straightforward: cin reads input according to the type of the destination variable. For example, int

Performance and portability notes: To improve I/O performance, programmers may disable synchronization with C I/O by

x;
std::cin
>>
x;
reads
an
integer
from
input.
The
operator>>
skips
leading
whitespace
and
stops
at
a
character
that
does
not
match
the
target
type,
leaving
any
remaining
input
(such
as
a
trailing
newline)
in
the
buffer.
To
read
an
entire
line
of
text,
programs
often
use
std::getline
in
combination
with
cin
and
handle
leftover
newlines.
By
default,
cin
is
an
instance
of
std::istream
and
is
tied
to
std::cout,
meaning
input
operations
may
flush
the
output
buffer
before
reading;
this
tie
can
be
disabled
for
performance.
calling
ios::sync_with_stdio(false)
and
untie
cin
from
cout
with
cin.tie(nullptr).
These
changes
affect
interaction
with
C-style
I/O
and
should
be
used
consistently
within
a
program.
Beyond
programming,
the
string
“Cin”
or
its
capitalized
form
can
appear
as
a
proper
noun
in
unrelated
contexts,
such
as
personal
names
or
place
names,
but
those
uses
are
not
related
to
the
C++
feature.