IO Overview CSCE 121 Strongly influenced by slides created by Bjarne Stroustrup and Jennifer Welch.

Slides:



Advertisements
Similar presentations
Chapter 10 Input/Output Streams
Advertisements

Slide: 1 Interra Induction Training Object Oriented Programming in C++ IO Streams Kolkata, July 25, 2005.
CS-1030 Dr. Mark L. Hornick 1 IOStreams revisited Streams, strings, and files.
1 Lecture 31 Handling Selected Topics Again!! File I/O Special Lectures.
Three types of computer languages
Input/Output Main Memory istream ostream Disk Drive Keyboard Scanner Disk Drive Monitor Printer stream = sequence of bytes.
C++ plus. 2 Goals Some general C++ tips 3 C++ Tips is header file for a library that defines three stream objects Keyboard an istream object named cin.
1 Lecture 5: Input/Output (I) Introduction to Computer Science Spring 2006.
 Wednesday, 10/16/02, Slide #1 CS106 Introduction to CS1 Wednesday, 10/16/02  QUESTIONS??  Today:  Return and discuss Test #1  Input from and output.
Chapter 8: I/O Streams and Data Files. In this chapter, you will learn about: – I/O file stream objects and functions – Reading and writing character-based.
How to Program in C++ CHAPTER 3: INPUT & OUTPUT INSTRUCTOR: MOHAMMAD MOJADDAM.
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.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
COMPUTER PROGRAMMING. Introduction to C++ History Merges notions from Smalltalk and notions from C The class concept was borrowed from Simular67 Developed.
UNFORMATTED INPUT OUTPUT. Topics to be discussed……………….. overloaded operators >> and and
CSCE 121: Introduction to Program Design and Concepts J. Michael Moore Fall 2014 Set 11: More Input and Output 1 Based on slides created by Bjarne.
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.
Computer Engineering 1 nd Semester Dr. Rabie A. Ramadan 2.
Chapter 10 Input/Output Streams John Keyser’s Modifications of Slides by Bjarne Stroustrup
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.
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
C++ for Engineers and Scientists Second Edition Chapter 8 I/O File Streams and Data Files.
File I/O ifstreams and ofstreams Sections 11.1 &
Chapter 9 I/O Streams and Data Files
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
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.
1 CS161 Introduction to Computer Science Topic #13.
File handling in C++ BCA Sem III K.I.R.A.S. Using Input/Output Files Files in C++ are interpreted as a sequence of bytes stored on some storage media.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 3: Input/Output.
Slides adapted from: Bjarne Stroustrup, Programming – Principles and Practice using C++ Chapter 10 Input/Output Streams Hartmut Kaiser
File I/O 1 ifstreams and ofstreams Sections 11.1 & 11.2.
FILE I/O IN C++. Using Input/Output Files A computer file  is stored on a secondary storage device (e.g., disk);  is permanent;  can be used to provide.
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.
Chapter -7 Basic function of Input/output system basics and file processing Stream classes : I/O Streams. A stream is a source or destination for collection.
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.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 9. Streams & Files.
CSCE 121: Introduction to Program Design and Concepts Dr. J. Michael Moore Spring Fall 2016 Set 10: Input/Output Streams 1 Based on slides created.
File Processing Files are used for data persistance-permanent retention of large amounts of data. Computer store files on secondary storage devices,such.
Slides adapted from: Bjarne Stroustrup, Programming – Principles and Practice using C++ Chapter 10 Input/Output Streams Hartmut Kaiser
File I/O in C++ I. Using Input/Output Files A computer file is stored on a secondary storage device (e.g., disk); is permanent; can be used to provide.
1 Stream Input and Output Read Text, page Keyboard and Screen I/O #include cin (of type istream) cout (of type ostream) KeyboardScreen executing.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the differences between text and binary files ❏ To write programs.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني I/O and File management Concept of streams. cin and cout objects. C++stream classes. Unformatted I/O.
Programming II I/O Streams and Data Files 1(c) Asma AlOsaimi.
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
Standard C++ Input/Output and String Classes
Introduction to C++ (Extensions to C)
Computer Engineering 1nd Semester
Basic Input and Output Operations
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
week 1 - Introduction Goals
Anatomy of a Function Part 2
Chapter 10 Input/Output Streams
Basic File I/O and Stream Objects
IO Overview CSCE 121 J. Michael Moore
Manipulators CSCE 121 J. Michael Moore
Chapter 3: Input/Output
CSC 143 Stream I/O Classes and Files [A11-A15, A38-A50]
File I/O.
Chapter 10 Input/Output Streams
Guidelines for Writing Functions
ENERGY 211 / CME 211 Lecture 9 October 10, 2008.
Input/Output Streams, Part 1
Introduction to Programming
Presentation transcript:

IO Overview CSCE 121 Strongly influenced by slides created by Bjarne Stroustrup and Jennifer Welch

cin & cout Standard in Standard out Standard error Where input comes into a program by default Normally the keyboard Can be modified (e.g. pipes in UNIX) Standard out Where output is sent Normally the screen Can be modified (e.g. pipes) Standard error Where error messages are sent Frequently set to a file cin cout cerr clog Standard in Standard out Standard err buffered error Keyboard Monitor Default: Same as cout Default: Same as cerr Apparently, clog is the same as cerr, just buffered. Example: $ ./prgm [ARGS] 0<IN 1>OUT 2>ERR

Input and Output (IO or I/O) Program Output

Input and Output (IO or I/O) data source: input library input device device driver our program data destination: output library device driver output device

The Stream Model An ostream Values of various types ‘c’ “somewhere” ostream 1.234 Values of various types 123 buffer An ostream turns values of various types into character sequences sends those characters somewhere (console, file, main memory, another computer…)

The Stream Model An istream Values of various types ‘c’ “somewhere” istream 1.234 Values of various types 123 buffer An istream gets characters from somewhere (console, file, main memory, another computer,…) turns character sequences into values of various types

The Stream Model Supports reading and writing of typed entities << (output) and >> (input/extraction) plus other operations type-safe formatted typically stored as text but not necessarily, e.g, binary streams extensible define your own I/O operations for your own types a stream can be attached to any I/O or storage device

Many different Streams What applies to cout/cin will also apply to file streams string streams Etc.

Model http://www.cplusplus.com/reference/iolibrary/