Home

Stdin

Standard input, or stdin, is a standard data stream used for reading input by a program. It is one of the three standard I/O streams defined by many operating systems and programming environments, alongside standard output (stdout) and standard error (stderr). By default, stdin is connected to the keyboard in interactive programs but it can be redirected from files, devices, or other programs.

In C and C++ with the standard library, stdin is a FILE* object defined in stdio.h. It

Shells and many programming languages support redirecting or piping data into stdin. In command lines, you

Examples by language: In Python, input() reads a line from stdin. In Java, System.in provides an InputStream

Notes: Stdin is not a file by itself; it is a stream abstraction that may refer to

is
normally
buffered,
and
input
functions
such
as
getchar,
fgets,
and
scanf
read
from
it.
In
POSIX
terms,
the
standard
input
corresponds
to
file
descriptor
0;
the
read(2)
system
call
reads
from
this
descriptor.
The
actual
source
can
be
a
terminal,
a
file,
or
a
pipe.
can
supply
input
from
a
file
using
program
<
input.txt,
or
pipe
output
from
one
command
into
another
using
command1
|
command2.
If
there
is
no
redirection,
programs
running
in
a
terminal
usually
read
from
the
keyboard.
for
stdin
(often
used
with
a
Scanner).
In
JavaScript
(Node.js),
process.stdin
is
a
stream
used
to
read
data.
In
C,
scanf
and
fgets
read
from
stdin;
in
shells,
builtins
like
read
read
from
stdin.
various
input
sources.
It
is
central
to
scripting
and
batch
processing,
enabling
non-interactive
input
handling
and
data
pipelines.