C and C++ Programming Resources | C & C++ Code Example Index





The C++ Formatted Input-output Sample Codes Index Page


The following links demonstrate the C++ program examples on the formatted input/output. Formatted input/output deals with the format to be written to and to be read from the standard output and standard input respectively. Other non-standard input/output also need to be formatted such as cerr. In C++ we learn how to use the member functions/methods that are already available in the class library.


C++ Formatted Input/Output



  1. Using the setw(), setiosflags() classes, ios::showpos and ios::internal methods C++ program sample

  2. Using the fill() member function and setfill() manipulator C++ program sample

  3. Using ios::showbase to print integers in hexadecimal and octal base number C++ program example

  4. Printing the floating number in system default, scientific and fixed format C++ program sample

  5. The ios::uppercase flag to display scientific notation-exponents and hexadecimal values in uppercase C++ code sample

  6. The flags() member function - cout.flags(), sets or returns the current flag settings C++ program example

  7. Using the eof(), fail(), bad(), good(), clear() and rdstate() methods C++ program example

  8. Using setw(), setiosflags(), resetiosflags() manipulators in C++ programming for output formatting

  9. Using showpoint (setf(ios::showpoint)) in controlling the trailing zeroes and floating points for standard output in C++ programming

  10. Using width member function: cout.width(), cin.width() in C++ programming

  11. Using the setprecision(), precision() methods in C++ programming to print float/double in the desired precisions

  12. The hex, oct, dec numbering base system and setbase() stream manipulator C++ code example

  13. The read(), write() and gcount() member functions used to read from standard input, write to standard output and counting the number of characters

  14. The cin.getline() methods to read a line of text from the standard input C++ code sample



  1. The C++ cin.get(), cin.eof() and cout.put() methods and end-of-file (EOF) controls code example

  2. The C++ formatted input and output using the standard console output, cout (<<) and console input, cin (>>) code sample

  3. Concatenating lateral string using the C++ redirection operator, << code example

  4. The C++ formatted output using the console output, cout<< program example

  5. The cout, cin, function call and array C++ program example

  6. Printing to the standard output using cout<< C++ program sample

  7. A simple stream input and output using cin and cout C++ program example

  8. Another C++ program example on how to use the cin to read from standard input continuously

  9. A very simple C++ code sample on how to use cin, to read from the standard input

  10. How to use the C++ stream extraction operator with sample code


C and C++ Programming Resources | C & C++ Code Example Index | C Code Example Index