In the C programming language, input/output library refers to a family of class templates and supporting functions in the C Standard Library that implement stream-based input/output capabilities. It is an object-oriented alternative to C's FILE-based streams from the C standard library. Dev C For Windows; Publisher's Description. The fact that iostream.h, an essential C.h file, is absent makes me wonder what other files that are needed for C are missing. May 02, 2012 Visual C iostream.h iostream. Java Project Tutorial - Make Login and Register Form Step by Step Using NetBeans And MySQL Database - Duration: 3:43:32. 1BestCsharp blog 4,426,580 views.
- The C Standard Library
- The C++ Standard Library
- The C++ STL Library
- C++ Programming Resources
- Selected Reading
Description
It is used in standard Input / Output Streams Library.
Declaration
Following is the declaration for iosstream function.
C++98
C++11
Objects
The objects of iosstream should be like this −
Narrow characters (char)
Sr.No. | Characters | Definition |
---|---|---|
1 | cin | Standard input stream |
2 | cout | Standard output stream |
3 | cerr | Standard output stream for errors |
4 | clog | Standard output stream for logging |
Wide characters (wchar_t)
Sr.No. | Characters | Definition |
---|---|---|
1 | wcin | Standard input stream (wide) |
2 | wcout | SStandard output stream (wide) |
3 | wcerr | Standard output stream for errors (wide-oriented) |
4 | wclog | Standard output stream for logging (wide) |
Declares objects that control reading from and writing to the standard streams. This include is often the only header you need to do input and output from a C++ program.
Syntax
Note
The <iostream> library uses the #include <ios>
, #include <streambuf>
, #include <istream>
, and #include <ostream>
statements.
Remarks
The objects fall into two groups:
cin, cout, cerr, and clog are byte oriented, doing conventional byte-at-a-time transfers.
wcin, wcout, wcerr, and wclog are wide oriented, translating to and from the wide characters that the program manipulates internally.
Once you do certain operations on a stream, such as the standard input, you can't do operations of a different orientation on the same stream. Therefore, a program can't operate interchangeably on both cin and wcin, for example.
All the objects declared in this header share a peculiar property — you can assume they're constructed before any static objects you define, in a translation unit that includes <iostream>. Equally, you can assume that these objects aren't destroyed before the destructors for any such static objects you define. (The output streams are, however, flushed during program termination.) Therefore, you can safely read from or write to the standard streams before program startup and after program termination.
This guarantee isn't universal, however. A static constructor may call a function in another translation unit. The called function can't assume that the objects declared in this header have been constructed, given the uncertain order in which translation units participate in static construction. To use these objects in such a context, you must first construct an object of class ios_base::Init.
Global Stream Objects
cerr | Specifies the cerr global stream. |
cin | Specifies the cin global stream. |
clog | Specifies the clog global stream. |
cout | Specifies the cout global stream. |
wcerr | Specifies the wcerr global stream. |
wcin | Specifies the wcin global stream. |
wclog | Specifies the wclog global stream. |
wcout | Specifies the wcout global stream. |
cerr
The object cerr
controls output to a stream buffer associated with the object stderr
, declared in <cstdio>.
Return Value
An ostream object.
Remarks
The object controls unbuffered insertions to the standard error output as a byte stream. Once the object is constructed, the expression cerr.
flags&
unitbuf is nonzero, and cerr.tie() &cout
.
Example
cin
Specifies the cin
global stream.
Return Value
An istream object.
Remarks
The object controls extractions from the standard input as a byte stream. Once the object is constructed, the call cin.
tie returns &
cout.
Example
In this example, cin
sets the fail bit on the stream when it comes across non-numeric characters. The program clears the fail bit and strips the invalid character from the stream to continue.
clog
Specifies the clog
global stream.
Return Value
An ostream object.
Remarks
The object controls buffered insertions to the standard error output as a byte stream.
Example
See cerr for an example of using clog
.
cout
Specifies the cout
global stream.
Return Value
An ostream object.
Remarks
The object controls insertions to the standard output as a byte stream.
Example
See cerr for an example of using cout
.
wcerr
Specifies the wcerr
global stream.
Return Value
A wostream object.
Remarks
Dev C++ Iostream Hatası
The object controls unbuffered insertions to the standard error output as a wide stream. Once the object is constructed, the expression wcerr.
flags&
unitbuf is nonzero.
Example
See cerr for an example of using wcerr
.
wcin
Specifies the wcin
global stream.
Return Value
Dev C++ Iostream.h
A wistream object.
Remarks
The object controls extractions from the standard input as a wide stream. Once the object is constructed, the call wcin.
tie returns &
wcout.
Example
See cerr for an example of using wcin
.
wclog
Specifies the wclog
global stream.
Return Value
A wostream object.
Remarks
The object controls buffered insertions to the standard error output as a wide stream.
Example
See cerr for an example of using wclog
.
wcout
Specifies the wcout
global stream.
Return Value
A wostream object.
Remarks
The object controls insertions to the standard output as a wide stream.
Example
See cerr for an example of using wcout
.
CString
instances in a wcout
statement must be cast to const wchar_t*
, as shown in the following example.
For more information, see Basic CString Operations.
See also
Header Files Reference
Thread Safety in the C++ Standard Library
iostream Programming
iostreams Conventions