1 Lab Session-XIII CSIT121 Fall 2000 b Lab Exercise13-A for Handling Files b Lab Exercise 13-B for Using Classes.

Slides:



Advertisements
Similar presentations
C++ provides the following classes to perform output and input of characters to/from files: ofstream: Stream class to write on filesofstream ifstream:
Advertisements

1 Engineering Problem Solving With C++ An Object Based Approach Chapter 4 Programming with Data Files.
1 Lab Session-1 CSIT221 Fall 2002 b Refresher slides b Practice Problem b Lab Exercise (Demo Required)
1 Lecture 31 Handling Selected Topics Again!! File I/O Special Lectures.
1 11/3/08CS150 Introduction to Computer Science 1 Reading from and Writing to Files Section 3.12 & 13.1 & 13.5.
1 Session-12 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-5 due date extended to March 7 Test-1 is on March 9 th ; Demo-5 due date extended to March.
1 Lab Session-2 CSIT221 Spring 2003 b Intro to Object Oriented Programming b Practice Problem b Lab Exercise (Demo Required)
1 Lab Session-XIV CSIT121 Fall 2000 b Tips for good programming b Complete Lab Exercise 13-B for Using Classes b Work on developing an object oriented.
1 Pre-Exam Class CSIT121 Fall 2000 Exam-II (Final Examination) TUESDAY DECEMBER 19th 8:30AM.
1 Lab Session-3 CSIT221 Spring 2003 b Group Worksheet 3 Exercise (Demo Required) b No new lab demo will be assigned to allow you to focus on HW#1.
1 Lab Session-XIV CSIT121 Spring 2002 b Namespaces b First Class Travel b Lab Exercise 14 (Demo) b Lab Exercise b Practice Problem.
1 Lab Session-III CSIT121 Fall 2000 Setting Your Own Paths Setting Project Information Browse Information Generation Data types revisited Enumerated data.
1 10/29/07CS150 Introduction to Computer Science 1 Reading from and Writing to Files Section 3.12 & 13.1 & 13.5.
1 Lab Session-5 CSIT221 Spring 2003 Default and Parameterized Constructors Destructors Programming Exercise for building a template based class (demo required)
1 Session-11 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-4 due Now Chapter 4 topics –Using get and ignore to control input data (3-19) –Prompting.
1 Exam Guide CSIT121 Summer-I 2001 Exam-II (Final Examination) Thursday June 28th 9:30AM.
1 Lab Session-VIII CSIT-121 Fall 2000 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
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.
1 10/25/06CS150 Introduction to Computer Science 1 Reading from and Writing to Files.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
1 Lab Session-VIII CSIT-121 Spring 2002 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
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.
Program Input and the Software Design Process ROBERT REAVES.
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 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
STREAMS AND FILES OVERVIEW.  Many programs are "data processing" applications  Read the input data  Perform sequence of operations on this data  Write.
Chapter 9 I/O Streams and Data Files
Topics 1.File Basics 2.Output Formatting 3.Passing File Stream Objects to Functions 4.More Detailed Error Testing 5.Member Functions for Reading and 6.Writing.
Data Types & I/O Streams Objectives Data Types Understand that integers form the underlying foundation for many data types. Introduce a few frequently.
CS Midterm Study Guide Fall General topics Definitions and rules Technical names of things Syntax of C++ constructs Meaning of C++ constructs.
TEXT FILES. CIN / COUT REVIEW  We are able to read data from the same line or multiple lines during successive calls.  Remember that the extraction.
File I/O in C++ II. Open() function Open() is a member function in each classes ( fstream, ifstream, ofstream) Void fstream :: open ( const char *filename,
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Managers and “mentors” identified on projects page. All member accounts created and projects populated.
Input/Output CSci 588: Data Structures, Algorithms and Software Design Fall 2011 All material not from online sources copyright © Travis Desell, 2011
File Handling in C++.
Engineering Problem Solving with C++, Second Edition, J. Ingber 1 Engineering Problem Solving with C++, Etter/Ingber Chapter 4 Working with Data Files.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 9. Streams & Files.
Lecture 14 Arguments, Classes and Files. Arguments.
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.
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.
CS 1430: Programming in C++ 1. File Input in VS Project Properties Debugging Command Arguments quiz8-1.out We want to know how to do it ourselves, right?
Ms N Nashandi Dr SH Nggada 2016/01/03Ms N Nashandi and Dr SH Nggada1 Week 6 -File input and output in C++
Computer Programming II Lecture 9. Files Processing - We have been using the iostream standard library, which provides cin and cout methods for reading.
Programming II I/O Streams and Data Files 1(c) Asma AlOsaimi.
CS212: Object Oriented Analysis and Design
CS212: Object Oriented Analysis and Design
ifstreams and ofstreams
File Processing in C++ Data is stored in files so that it may be retrieved for processing when needed.
Chapter 7 Text Input/Output Objectives
Chapter 7 Text Input/Output Objectives
Introduction to Programming
Chapter 7 Text Input/Output Objectives
Functions Manipulating Files
COMP 2710 Software Construction File I/O
CISC/CMPE320 - Prof. McLeod
File I/O.
Programming with Data Files
when need to keep permanently
Standard Input/Output Stream
File Processing in C++ Data is stored in files so that it may be retrieved for processing when needed.
Class Examples.
Programming Assignment 1
File I/O in C++ I.
Reading Data From and Writing Data To Text Files
File Streams 12/09/13.
ifstreams and ofstreams
ENERGY 211 / CME 211 Lecture 9 October 10, 2008.
File I/O in C++ II.
Lecture 9 Files Handling
File I/O in C++ I.
Presentation transcript:

1 Lab Session-XIII CSIT121 Fall 2000 b Lab Exercise13-A for Handling Files b Lab Exercise 13-B for Using Classes

2 File I/O b Include fstream to enable file I/O b Declare an object of type “ifstream” if reading from a file b Declare an object of type “ofstream” if writing to a file b Report error if file open fails

3 File I/O b Use get and put to handle characters b Use >> and > and << to handle numbers and strings b Check for End of File with eof() member function of stream object b Close files after use

4 Lab Exercise 13-A for File I/O b b Read the text file provided as “sample.txt” and write a program that allows a user to select one function out of the following: Changing all letters to uppercase Changing first letter of every word to uppercase #include and toupper() function)(Use #include and toupper() function)

5 Handling Classes b You have to plan for implementing a program with classes b Decide about the structure of the class, its private and public members b Then define the class in a header file and implement its functions in an implementation file b Develop the client code later to use the objects that belong to this class

6 Lab Exercise 13-B for Handling Classes b A vending machine contains fruit juices and soft drinks. It can have a maximum of 10 apple juice cans, 10 orange juice cans, 10 mixed juice cans, 10 pepsi cans and 10 sprite cans. Users can buy one can at a time and more items can be added to the machine

7 Lab Exercise 13-B b Develop a program that models this vending machine as an object. It should have all items as private data items and buy/add functions as public functions. There should be another public function show() that shows (prints) all items and their current quantity available.