Introduction to Programming

Slides:



Advertisements
Similar presentations
M The University Of Michigan Andrew M. Morgan Andrew M Morgan1 EECS Lecture 05 Savitch Ch Streams Stream States Input/Output.
Advertisements

This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Operator Overloading. Introduction Operator overloading –Enabling C++’s operators to work with class objects –Using traditional operators with user-defined.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 8 - Operator Overloading Outline 8.1 Introduction 8.2 Fundamentals of Operator Overloading 8.3.
LECTURE 17 C++ Strings 18. 2Strings Creating String Objects 18 C-string C++ - string \0 Array of chars that is null terminated (‘\0’). Object.
CMSC 2021 C++ I/O and Other Topics. CMSC 2022 Using C++ Stream I/O Default input stream is called cin Default output stream is called cout Use the extraction.
I/O and Program Control Statements Dick Steflik. Overloading C++ provides two types of overloading –function overloading the ability to use the same function.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
Input/Output Main Memory istream ostream Disk Drive Keyboard Scanner Disk Drive Monitor Printer stream = sequence of bytes.
C-Strings A C-string (also called a character string) is a sequence of contiguous characters in memory terminated by the NUL character '\0'. C-strings.
計算機概論實習 Stream Stream: sequence of bytes Input: from device (keyboard, disk drive) to memory Output: from memory to device (monitor, printer,
1 Lecture 5: Input/Output (I) Introduction to Computer Science Spring 2006.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
How to Program in C++ CHAPTER 3: INPUT & OUTPUT INSTRUCTOR: MOHAMMAD MOJADDAM.
CMSC 2021 Stream I/O Operators and Friend Functions.
Chapter 3: Input/Output
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 27P. 1Winter Quarter I/O Manipulation Lecture.
Streams, Files. 2 Stream Stream is a sequence of bytes Input stream In input operations, the bytes are transferred from a device to the main memory Output.
Input/Output in C++ C++ iostream.h instead of stdio.h Why change? –Input/output routines in iostream can be extended to new types declared by the user.
UNFORMATTED INPUT OUTPUT. Topics to be discussed……………….. overloaded operators >> and and
C++ Programming Certificate University of Washington Cliff Green
Stream Handling Streams - means flow of data to and from program variables. - We declare the variables in our C++ for holding data temporarily in the memory.
1 Advanced Input and Output COSC1567 C++ Programming Lecture 9.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
Ch 10. Input/Output1 Ch. 10 Input/Output Oregon State University Timothy Budd.
C++ Lecture 8 Monday, 25 August I/O, File, and Preprocessing l An in-depth review of stream input/output l File handling in C++ l C++ preprocessing.
Chapter 10C++ for Java Programmers1 Chapter 10 Input/Output.
1 Streams In C++, I/O occurs in streams. A stream is a sequence of bytes Each I/O device (e.g. keyboard, mouse, monitor, hard disk, printer, etc.) receives.
I/O and Data Formatting Introduction to Class Concepts INFSY 307 Spring 2003 Lecture 3.
Input/Output Sujana Jyothi C++ Workshop Day 2. C++ I/O Basics 2 I/O - Input/Output is one of the first aspects of programming that needs to be mastered:
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
1 Simple Input/Output  C++ offers the iostream library, which defines a system of character-oriented Input/Output (I/O) using object oriented programming.
Lecture Contents I/O Streams. –Input/output streams. –Unformatted vs formatted streams. –Stream manipulators. –Stream error state. –Stream tying. –Examples.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 21 - C++ Stream Input/Output Basics Outline 21.1Introduction 21.2Streams Iostream Library.
1 Today’s Objectives  Announcements Turn in Homework 4 Quiz 4 will be on Wednesday, July 19 – It will have questions about inheritance, polymorphism,
CSC 143A 1 CSC 143 Introduction to C++ [Appendix A]
Chapter 11 Standard C++ Strings and File I/O Dept of Computer Engineering Khon Kaen University.
Programming Fundamentals. Today’s Lecture Multidimensional Arrays Arrays as Class Member Data Arrays of Objects C-Strings.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
1 COMS 261 Computer Science I Title: Functions Date: October 24, 2005 Lecture Number: 22.
Streams One of the themes of this course is that everything can be reduced to simple (and similiar) concepts. Streams are one example. Keyboard and Screen.
Input/Output in C++ C++ iostream.h instead of stdio.h Why change? –Input/output routines in iostream can be extended to new types declared by the user.
Exploring the C++ Stream Library Copyright 2006 Oxford Consulting, Ltd1 February IO Streams  IOStreams are part of the Standard C++ library.
24 4/11/98 CSE 143 Stream I/O [Appendix C]. 25 4/11/98 Input/Output Concepts  Concepts should be review!  New syntax, but same fundamental concepts.
Copyright © 2006 Pearson Addison-Wesley. All rights reserved Today’s Lecture  I/O Streams  Console I/O  File I/O  Tools for File I/O  Sequential.
CSE 232: Moving Data Within a C++ Program Moving Data Within a C++ Program Input –Getting data from the command line (we’ve looked at this) –Getting data.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني I/O and File management Concept of streams. cin and cout objects. C++stream classes. Unformatted I/O.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
Introduction Every program takes some data as input and generate processed data as out put . It is important to know how to provide the input data and.
CS212: Object Oriented Analysis and Design
Introduction to C++ (Extensions to C)
Standard Input - Output
Basic Input and Output Operations
Chapter 21 - C++ Stream Input/Output
IO Overview CSCE 121 J. Michael Moore
Today’s Lecture I/O Streams Tools for File I/O
Chapter 3: Input/Output
Chapter 12 - C++ Stream Input/Output
CSC 143 Stream I/O Classes and Files [A11-A15, A38-A50]
Introduction to Programming
Chapter 3: Expressions and Interactivity
C++ Stream Input/Output
do/while Selection Structure
Strings Skill Area 313 Part C
Today’s Objectives 28-Jun-2006 Announcements
ENERGY 211 / CME 211 Lecture 9 October 10, 2008.
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
IO Overview CSCE 121 Strongly influenced by slides created by Bjarne Stroustrup and Jennifer Welch.
Input/Output Streams, Part 1
Presentation transcript:

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 ) Integer type to express counts in streams More than one 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

cin >> i >> j ; 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 How to create our own object We learnt Input / Output Stream cin , cout , cerr , clog How to create our own object Overload Stream Operators