0% found this document useful (0 votes)
22 views40 pages

Introduction To Programming

ppt cs201 lec 35

Uploaded by

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

Introduction To Programming

ppt cs201 lec 35

Uploaded by

Saeed ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 40

Introduction to Programming

Lecture 35
Input/Output
Streams
File
Input/Output
Stream
scanf ( ) ;
printf ( ) ;
Stream
Stream is an ordered
sequence of bytes
Stream
Input/Output
Input stream object
cin
Output stream object
cout
Stream Operators

>>
<<
Example
int i ;
char c ;
cin >> i ;
cin >> c ;
Every stream has:
– A source
– A destination
State
Example
int i , j ;
cin >> i >> j ;
cout << i / j ;
Formatted
Input / Output
Member Functions
cin.get ( ) ;
c = cin.get ( ) ;
cin.get ( char c ) ;
cin.read ( char * buffer , streamsize n )

More than one Integer type to express


counts in streams
character is read
<<
cout.put (char c ) ;
#include <iostream.h>
iomanip.h
cerr
clog
Buffered
Input/Output
Buffer
flush
“\n”
cout << endl ;
caux
cprn
cout << “The value of the first
integer is” << i ;
Stream
Insertion
Operator
ostream & ostream :: operator << ( char * text )
Stream
Extraction
Operator
Example
int i , j ;
cin >> i >> j ;
cin.getline ( char * buffer , int buff_size , char delimiter = ‘\n’ )

100
cin.unget ( ) ;
cin.peek ( ) ;
cout.put ( char ch ) ;
cout.write ( char * str , int n ) ;
Example
char name [ 60 ] ;
cin >> name ;
cout << name ;
Example

char name1 [ 30 ] , name2 [ 30 ] ;


cin >> name1 >> name2 ;
In Today’s Lecture
We learnt
 Input / Output Stream

cin , cout , cerr , clog


 How to create our own object
 Overload Stream Operators

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy