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.

Slides:



Advertisements
Similar presentations
© 2000 Scott S Albert Structured Programming 256 Chapter 7 Streams and File I/O.
Advertisements

CS 206 Introduction to Computer Science II 09 / 14 / 2009 Instructor: Michael Eckmann.
1 Lecture 31 Handling Selected Topics Again!! File I/O Special Lectures.
1 Session-17 CSIT 121 Spring 2006 Loops: Conditional and Count Controlled Loops: Conditional and Count Controlled LCV: Initialize; Test and Update LCV:
1 Session-16 CSIT 121 Spring 2006 Demo for switch-case due now Demo for switch-case due now String comparison String comparison Slide 23; sample case.
1 Session-5 CSIT 121 Spring 2006 Part D due now String Rules Chapter 2 Topics Lab Demo Exercise Assignment.
CS 206 Introduction to Computer Science II 09 / 04 / 2008 Instructor: Michael Eckmann.
1 Lecture 32 Handling Selected Topics Again!! Structs and Arrays of Structs Special Lectures.
1 Session-23 CSIT 121 Spring 2006 Revision Ch 7: Reference Parameters Revision Ch 7: Reference Parameters Chapter 8: Value Returning Functions Chapter.
1 Lecture 19 Chapter 4 Program Input and the Software Design Process Dale/Weems/Headington.
1 Session-I & II CSIT-121 Spring 2006 Session Targets Introducing the VC++.NET Solving problems on computer Programming in C++ Writing and Running Programs.
1 Lab Session-1 CSIT221 Spring 2003 b Group Programming Challenge b Individual Lab Exercise (Demo Required)
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.
Review for midterm exam Dilshad M. Shahid Spring NYU.
1 Session-15 CSIT 121 Spring 2006 Selection with Switch~Case Selection with Switch~Case Need an integer or character to test for Need an integer or character.
1 Lab Session-2 CSIT 121 Spring 2005 Debugging Tips NiMo’s Varying Rates Lab-2 Exercise.
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 Lab Session-XIII CSIT121 Fall 2000 b Lab Exercise13-A for Handling Files b Lab Exercise 13-B for Using Classes.
1 Lab Session-6 CSIT-121 Spring 2005 Structured Choice The do~While Loop Lab Exercises.
1 Lab Session-3 CSIT 121 Spring’05 Division rules Operator precedence rules Lab Exercise.
1 Lab Session-VIII CSIT-121 Fall 2000 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
1 Lab Session-11 CSIT 121 Fall 2003 Using arrays in functions Programming Exercise.
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 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.
CS 206 Introduction to Computer Science II 01 / 23 / 2009 Instructor: Michael Eckmann.
1 Session-13 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.
1 Lab 2 CSIT-120 Fall 2000 Session II-A (September 14th) Operations on Data Lab Exercise 2-A Data Types Variables Lab Exercise 2-B Session II-B (September.
1 Lab Session-VIII CSIT-121 Spring 2002 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
Program Input and the Software Design Process ROBERT REAVES.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 13 Files and Exception Handling 1.
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.
1 Lab Session-8 CSIT-121 Spring 2005 Call by Reference Lab Exercise for Demo Practice Problems.
Chapter 9 1 Chapter 9 – Part 1 l Overview of Streams and File I/O l Text File I/O l Binary File I/O l File Objects and File Names Streams and File I/O.
INT213 Week 1.  A Named storage area (in RAM) that can hold a value (like a mailbox holding a letter)  Contents of a variable can be assigned, changed.
1 CS161 Introduction to Computer Science Topic #13.
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.
CS Midterm Study Guide Fall General topics Definitions and rules Technical names of things Syntax of C++ constructs Meaning of C++ constructs.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
Chapter 9 Streams: Input stream: source of characters. Output stream: destination for characters. Up to now the input stream has defaulted to the keyboard.
Basics of Most C++ Programs // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose:
CNG 140 C Programming (Lecture set 10) Spring Chapter 10 Data Files.
1 Simple File I/O Chapter 11 Switch Statement Chapter 12.
Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors in transcription or understanding. If there.
MIS 3200 – Unit 5.1 Iteration (looping) – while loops – for loops Working with List Items.
1 Project 3 String Methods. Project 3: String Methods Write a program to do the following string manipulations: Prompt the user to enter a phrase and.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
Writing to Files and Reading From Files. Writing Data to a File Creating a new file, a.dat or.txt file #include #include // for file writing #include.
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
File I/O. Files allow permanent storage of programs and data. ifstream and ofstream objects –For file I/O the inclusion of is required. –Objects for file.
Dictionaries and File I/O George Mason University.
C++ Objects and Scope. Important Definitions  Class  Access and Visibility  Encapsulation  Unified Modeling Language (UML)  Constructor  Destructor.
Computer Programming II Lecture 9. Files Processing - We have been using the iostream standard library, which provides cin and cout methods for reading.
File I/O. I/O Flags Flags are passed to give some information about how the file is to be used. – Read only file – flag=0x0 – Write only file – flag=0x1.
INT213 – WEEK 1 ASP tags and comments Variables, Constants, and "Literals" Simple Output.
Topics discussed in this section:
What’s cheating and what is not?
Lab Session-9 CSIT-121 Spring 2005
Exception Handling Chapter 9.
When I want to execute the subroutine I just give the command Write()
Standard Input/Output Stream
What's wrong with Easter jokes? They crack you up
MIS 3200 – Unit 5.1 Iteration (looping) Working with List Items
CS 2 2/25/2015 File Exists?.
Final Revision sheet- term2
Lecture 3 More on Flow Control, More on Functions,
Topics discussed in this section:
String Handling.
Challenge Guide Grade Code Type Slides
Threads and concurrency / Safety
Presentation transcript:

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 7 Revision of some topics Revision of some topics Global versus local variables Global versus local variables Using get to count total number of characters in a text file Using get to count total number of characters in a text file Accepting filename at run time Accepting filename at run time Checking for errors in file I/O Checking for errors in file I/O

2 Globals and Locals Any variable declared within a function is visible only within that function Any variable declared within a function is visible only within that function Let us run some sample programs provided in session 9 slides Let us run some sample programs provided in session 9 slides

3 Using get to count characters MS-Word has a counter that counts total characters in a file MS-Word has a counter that counts total characters in a file You can design a counter for text files that counts every character in the file You can design a counter for text files that counts every character in the file The text file is available on the lectures page (name “news.txt”). Let us design the program The text file is available on the lectures page (name “news.txt”). Let us design the program

4 Accepting file name at run time Let us include the following code to make the program accept file name at run time Let us include the following code to make the program accept file name at run time string filename; string filename; ifstream texty; ifstream texty; cout<<“please enter filename”; cout<<“please enter filename”; getline(cin,filename); getline(cin,filename); texty.open(filename.c_str()); texty.open(filename.c_str());

5 Detecting errors in opening file What type of errors are expected? What type of errors are expected? How to handle the errors? How to handle the errors? After running the open call, check if the file was really opened with the following code segment: After running the open call, check if the file was really opened with the following code segment: if (!texty) cout<<"File not found"<<endl; if (!texty) cout<<"File not found"<<endl;