Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming

Similar presentations


Presentation on theme: "Introduction to Programming"— Presentation transcript:

1 Introduction to Programming
Lecture 35

2 Input/Output Streams

3 File Input/Output

4 Stream

5 scanf ( ) ; printf ( ) ;

6 Stream Stream is an ordered sequence of bytes

7 Stream Input/Output

8 Input stream object cin Output stream object cout

9 Stream Operators >> <<

10 Example int i ; char c ; cin >> i ; cin >> c ;

11 Every stream has: A source A destination

12 State

13 Example int i , j ; cin >> i >> j ; cout << i / j ;

14 Formatted Input / Output

15 Member Functions

16 cin.get ( ) ;

17 c = cin.get ( ) ; cin.get ( char c ) ;

18 cin.read ( char * buffer , streamsize n )
Integer type to express counts in streams More than one character is read

19 <<

20 cout.put (char c ) ;

21 #include <iostream.h>

22 iomanip.h

23 cerr clog

24 Buffered Input/Output

25 Buffer

26 flush

27 “\n”

28 cout << endl ;

29 caux cprn

30 cout << “The value of the first integer is” << i ;

31 Stream Insertion Operator

32 ostream & ostream :: operator << ( char * text )

33 Stream Extraction Operator

34 cin >> i >> j ;
Example int i , j ; cin >> i >> j ;

35 cin.getline ( char * buffer , int buff_size , char delimiter = ‘\n’ )
100

36 cin.unget ( ) ; cin.peek ( ) ;

37 cout.put ( char ch ) ; cout.write ( char * str , int n ) ;

38 Example char name [ 60 ] ; cin >> name ; cout << name ;

39 Example char name1 [ 30 ] , name2 [ 30 ] ;
cin >> name1 >> name2 ;

40 In Today’s Lecture How to create our own object
We learnt Input / Output Stream cin , cout , cerr , clog How to create our own object Overload Stream Operators


Download ppt "Introduction to Programming"

Similar presentations


Ads by Google