Basics Library in C++
Basics Library in C++
………………………………………………………………………………………………………………………………………………………………………………….
1 : “ iostream “
In C++, the iostream header provides functionality for input and output
operations. It includes declarations for the standard input/output
stream objects like std::cin, std::cout, std::cerr, and std::clog, as well as
various classes and functions for formatted input and output.
Cin Input Operations , It allows the program to receive
data entered by the user during runtime.
Cout it is commonly used for general-purpose output. is
(StandardOutput) often buffered . Meaning that the output is stored in
a buffer and flushed under certain conditions .
Cerr This stream is generally used for error messages or
(Standard Error) diagnostics. is typically unbuffered. This means that
the output is immediately flushed to the screen
without waiting for the buffer to fill up.
Clog typically used for producing log messages. It shares
(Standard Log) some characteristics with ‘’ cerr ‘’ , but it may be
buffered depending on the implementation.
2: “ fstream ”
The <fstream> header in C++ is part of the Standard Template Library
(STL) and provides facilities for working with file input and output. The
"f" in <fstream> stands for "file," indicating that this library is used for
file stream operations.
ifstream This class is used for reading data from
(Input File Stream) files. You can open an existing file for
reading and use “ std::ifstream ” to read
data from it.
Ofstream This class is used for writing data to files.
(Output File Stream) You can create a new file or overwrite an
existing file for writing using
“std::ofstream ”.
fstream This class provides a combination of
(File Stream) features from “ifstream and ofstream”. It
can be used for both reading and writing
to files. You can open a file for both
reading and writing, and you have more
flexibility in terms of file operations.
3 : “ iomanip “
The <iomanip> library in C++ is part of the Standard Template Library
(STL) and provides tools for manipulating the input and output streams,
primarily for formatting purposes.
setw(int n) Sets the width of the field for the next input
(Set Width) or output operation.
setprecision(int n) Sets the decimal precision for floating-point
(Set Precision) output.
fixed – Ensures that floating-point numbers are
(Fixed-Point Notation) displayed in fixed-point notation (rather
than scientific notation).
setfill(char c) Sets the fill character for the output field
(Set Fill Character(
setbase Set basefield flag
setiosflags Set format flags
resetiosflags Reset format flags
get_money Get monetary value
put_money Put monetary value
get_time Get date & time
put_time Put date & time
4 : “ String ”
String is a class and all objects that in string represent sequences of
characters.
5 : “ cmath ”
The C++ <cmath> header file declares a set of functions to perform
mathematical operations such as: sqrt() to calculate the square root,
log() to find natural logarithm of a number etc.
cos() Returns Cosine of the Argument
sin() Returns Sine of the Argument
tan() Returns Tangent of the Argument
pow() Computes Power a Number
sqrt() Computes Square Root of A Number
round() Returns integral value nearest to
argument
log() Returns Natural Logarithm of a
Number
remainder() Returns remainder of x/y