Sign In | Subscribe

Enter your Sign on user name and password.

Forgot password?
  • Follow us on:
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Intermediate C++
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Sign up for

Membership Overview

  • Unlimited access to our entire library of courses.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lesson files for programming and software training practice.
  • Track your course viewing progress.
  • Download lecture slides for taking notes.
  • Learn at your own pace... anytime, anywhere!

Input/ Output

  • Modify your program that implements the “Auto” class.
    • Don’t “hard-code” multiple loops to test; read the pedal pressures from a file.
    • Test your program by running it with different input files that test different scenarios.
    • Write output to a human-readable data file that you can review after the run.
    • Also write the data to a comma-separated values (CSV) file. Any labels are only on the first record. Each data point on each line is separated by a comma, and text data is enclosed in double-quotes. E.g.:
      • That way, you’ll be able to read the file into a spreadsheet program. Once in a spreadsheet, you do other computations or create graphs.
    • If you haven’t done so already, output each exception to a separate log file.
  • Validate the input from the file. Set the exception bits so that you can use exception handling.
  • Read the input from a CSV file. That is, use the comma as a field delimiter.
    • For example, the first column might be the value for the acceleration pedal, then the comma, then the second column can be the value for the brake pedal.
    • Use the “stringsteam” class as part of the validation, so you can read in an entire field up to the comma, then convert that value to a number for input.
    • Test that the entire field was a number, with no extraneous non-numeric, non-delimiter, non white-space character.
    • Put the result into a class or function which throws an exception of the data is not valid.
  • It can be useful for the input files to be self-documenting.
    • Read the first field on a line into a buffer, test the first character to see if it is a “comment character.” Typically the hash symbol (#) is used for line comments in cases like this. Process normally if it is not a comment line.
    • Skip over each line in a loop until the first character is not a comment.
    • Document your input files with comments as to what exactly is being tested.
  • Extra: There are additional ways to help document the testing process. Use a different “comment character” to indicate, “Print this line.” When your program sees that character at the beginning of the line, print the entire line to the output, including the exception log.
  • Run your program through its paces to test the various functions.

Input/ Output

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Overview 0:11
  • Streams 4:37
    • Byte Streams
    • Operator '<<' Overloaded for Output
    • Operator '>>' Overloaded for Input
  • I/O Class Hierarchy 6:46
    • ios_base
    • Input Stream
    • Output Stream
    • Multiply Inherits From istream, ostream
  • Buffer Class Hierarchy 9:27
    • Buffering Allows I/O to Work More Efficiently
    • 'Flushed'
    • Streambuf - Buffer for Data
  • Base Class Attributes 10:25
    • Formatting Information
    • State Information
  • Sub-Class Members 15:46
    • IOS Adds Additional Members and Methods
    • Error State Flags
  • Input Classes 20:31
    • istream - Input Character Stream
    • ifstream - Input File Character Stream
    • istringstream - Input String Character Stream
  • Output Classes 24:10
    • ostream - Output Character Stream
    • ofstream - Output File Character Stream
    • ostringstream - String Character Stream
  • Multiple Inheritance and Includes 25:59
    • iostream - Multiply Inherits From istream, ostream
    • Classic Example of Multiple Inheritance
    • fstream - Inherits From iostream
    • stringstream - Inherits From iostream
  • Detect Failures Using Status Bits 27:32
    • Test the Status Bits
    • Use Exceptions
  • Failure Bit Cautions 30:20
    • failbit Is Set on Formatted Input if the Input Stream Cannot be Parsed
    • Example
  • String I/O with Stringstream 32:21
    • Used for Input and Output
    • Example
  • Flushing Data buffer 35:39
    • Sometimes Buffering Is Not Desired
    • Input Flush Example
    • Output Flush Example
  • Internationalization 39:06
    • Complex Problem with Different Cultures
    • 'Imbue' I/O with Installed Locale Info
    • Set Size of a 'Character' for I/O
  • Confused Yet? 42:47