0% found this document useful (0 votes)
56 views6 pages

CPP GTU Study Material E-Notes Unit-6 14112019053345AM

Uploaded by

Pubg Mobile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
56 views6 pages

CPP GTU Study Material E-Notes Unit-6 14112019053345AM

Uploaded by

Pubg Mobile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
Darshan Unit-6 Managing Console I/O Operations Ina of ng Tec rile Ses Explain Input stream and Output stream in brief ‘* The I/O system supplies an interface to the programmer that is independent of the actual device being accessed. This interface is known as stream. * stream is a sequence of bytes. It acts either a source from which the input data can be obtained or as a destination to which the output data can be sent. '* The source stream that provides data to the program is called the input stream and the destination stream that receives output from the program is called the output stream. * other words, a program extracts the bytes from an input stream and inserts bytes into an output stream. Which is shown in the below figure: input stream | Program | Insertion Output Device Output Stream [Bom cnes + stream * We know that cin represents the input stream connected to the standard input device and cout represents the output stream connected to the standard output device. Header files available in C++ for Input - Output operation are: ‘© ostream: jostream stands for standard input output stream. This header file contains definitions to objects like cin, cout, cerr etc. ‘+ iomanip: iomanip stands for input output manipulators. The methods declared in this files are used for manipulating streams. This file contains definitions of setw, setprecision etc. * fstream: This header file mainly describes the file stream. This header file is used to handle the data being read from a file as input or data being written into the file as output. Example : #includeciostream> using namespace std; int main() { int age; cout << "Enter your agé cin >> age; cout << "\nYour age is: "<> Inherits the properties of ios, Declared output functions like put() and write(), Contains insertion operator << Inherits the properties of ios stream and ostream through multiple inheritance and this contains all the input and output functions. streambuf Provides an interface to physical devices through buffers Explain Unformatted I/O Operations istream (Input Stream) ‘ostream (Output Stream) iostream (I/O Stream) Overloaded Operators >> and <<: ‘* We have used the objects cin and cout for the input and output of data of various types. This has been made possible by overloading the operators >> and << to recognize all the basic C++ types. PROGRAMMING IN C++ (3330702) Hetasvi R. Ribadiya Darshan Unit-6 Managing Console I/O Operations nate of ng ech fr Dilan Se The >> operator is overloaded in the istream class and <> variable1 >> variable2>>.. >variableN; variable1,variable2....... are valid C+* variable names that have been declared already. This statement will cause the computer to stop the execution and look for input data from the keyboard Example is shown below; #include using namespace std; int main() { cout<<"This is the example of COUT"<>a; cout<<"Entered Value of a is: "< #include using namespace std; int main() { char cl; cout<<"First Method: Using get(* char}'"< Hinclude using namespace std; int main() { cout<<"Example of write() and getline() Function"< ffinclude using namespace std; int main() { cout.width(5); couts< 123 < #include #includeciomanip> using namespace std; int main() { coutc

You might also like