Enter your Sign on user name and password.

Forgot password?
Sign In | Subscribe
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 Introduction to C++
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Lecture Comments (9)

1 answer

Last reply by: Alvin Sylvain
Wed Oct 29, 2014 9:47 PM

Post by Ram Manohar Oruganti on October 29, 2014


So, if I were to use a C++ program in a Unix based OS should I use stdout instead of cout or did you mean stdout is a Unix command?

1 answer

Last reply by: Alvin Sylvain
Tue Jul 1, 2014 12:34 AM

Post by Kitt Parker on June 30, 2014

Good Evening,
I hope that you are able to provide some insight.  I'm currently working on a test program that will censor sensitive parts of a message.  Censor the entire sentence or ~~the line between two paragraphs identified by a zero character line~~  I seem to be unable to understand what this means,  how do I identify a zero character line? ><

2 answers

Last reply by: Kitt Parker
Thu Jun 12, 2014 8:11 AM

Post by Kitt Parker on June 11, 2014

Question concerning command line parameters.  Hope that you are able to provide a bit of insight.

I can tell that the arguments after the first one are not being passed in.  I can tell because if I switch the order, the new "1" will display through cout when called.  If correct, there must be some simple way to have the arguments accepted as expected.

I have int main

int main (int argc, char** argv){

 ifstream testIn    (argv[2]);

 ifstream testIn2   (argv[1]);
 ofstream reportOut (argv[3]);


1 answer

Last reply by: Alvin Sylvain
Wed Feb 26, 2014 11:30 AM

Post by mohab ahmed on February 25, 2014

I have a file and store array of structure  but the problem is I want to get data back in array of structure too but I don not know how to do this

Input/ Output (IO)

  • The simplest form of input and output for a C++ program uses what is known as Character Streams – where characters “stream” into or out of the program from/to some external source.
  • The objects we’ve used already, cin and cout, are external objects of classes inherited from “iostream” class.
  • Two additional objects are cerr and clog
  • “cin”, “cout”, “cerr” and “clog” are console streams. I/O is to the user terminal or console.
  • The stream classes include useful methods, such as “get()”, “put()”, “good()”, “eof()”, and others.
  • Streams can be formatted using I/O Manipulators
  • Formatting includes width, precision, scientific notation, etc.
  • Character streams can also connect from/to Files
  • The file stream classes include additional methods for file manipulation, such as “open()”, “close()”, “read()” and “write()”.
  • Here are links to more information about C++ input and output: http://www.cplusplus.com/doc/tutorial/basic_io/http://www.cplusplus.com/doc/tutorial/files/

Input/ Output (IO)

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:15
  • Character Input Streams 3:02
    • 'Getline' Method
  • Input Stream Object Methods 7:47
  • Input Examples 11:56
  • Character Output Streams 15:19
    • 'Cout' = Standard Output
    • 'Cerr' = Error Output
    • Insertion Operator
    • Format
  • Output Stream Object Methods 18:23
  • Output Examples 21:23
  • Formatting: I/O Manipulators 23:38
    • Set the Width
  • More I/O Manipulators 28:20
    • Scientific
    • Set Precision
    • Examples
  • File Input/Output 32:13
  • Output Streams 33:52
    • Insertion Operator
    • Example
  • Input Streams 36:50
    • Example
  • Error Messages 38:18
    • 'errno'
    • Example
  • File Example 41:06
  • Got Files? 42:58