1 / 86

C Stream Input

C Stream Input/output. C provides low level and high level I/O capabilitieslow level stream transfer deal with individual bytehigh level stream transfer deals with built-in data type and user-defined data types. C Stream Input/output. iostream library has hundreds of I/O capabilitiesiostre

helki
Télécharger la présentation

C Stream Input

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. C++ Stream Input/output C++ standard libraries provide an extensive set of input/output capabilities. Streams of bytes, a sequence of bytes bytes flows from devices to memory in input stream; from memory to devices in output stream I/O operations are very important procedure in computing

    2. C++ Stream Input/output C++ provides low level and high level I/O capabilities low level stream transfer deal with individual byte high level stream transfer deals with built-in data type and user-defined data types

    3. C++ Stream Input/output iostream library has hundreds of I/O capabilities iostream: basic input and output iomanip: parameterized stream manipulators fstream: file processing iostream library contains many I?O related classes, mainly istream and ostream istream and ostream are subclasses of ios base class

    5. C++ Stream Input/output operator overloading is applied to all of the iosteram classes cin is an instant of iostream class cin>>grade; cout is an instance of ostream class cout<<grade; buffer concept cerr and clog instnaces

    6. C++ Stream Input/output For file processing, C++ has the following classes

    7. C++ Stream Input/output stream-insert operator

    12. C++ Stream Input/output Cascading stream-insertion

    14. C++ Stream Input/output C++ automatically determine data types However we may have conflicts. For example, one wants to display the value of char pointer (expected to be a memory address)

    17. C++ Stream Input/output cout as a object of ostream has a special member function called put(). It can be used to display a individual character cout.put('F'); cout.put("J').put('u').put('n');

    18. C++ Stream Input/output Stream input

    23. C++ Stream Input/output A popular way to input a value to a variable using stream-extraction operation is in a while loop Example:

    26. C++ Stream Input/output get() and getline() member functions get() input one character put() is to display a character as we mentioned. example

    33. C++ Stream Input/output unformatted input/output is performed with the read and write member functions

    36. C++ Stream Input/output Stream manipulations: perform formatting of input and output tasks. integral stream base: dec, oct, hex, and setbase

    40. C++ Stream Input/output Stream manipulations: perform formatting of input and output tasks. floating-point precision (precision, setprecision)

    46. C++ Stream Input/output Field width (setw, width)

    50. C++ Stream Input/output User-defined manipulators

    55. C++ Stream Input/output Stream Format States setf, unsetf, flags member functions See table Fig 11.20 Format State Flags examples Trailing zeros and decimal points (ios::showpoint)

    59. C++ Stream Input/output Format State Flags examples Justification (ios::left, iosright, ios::internal)

    63. C++ Stream Input/output Format State Flags Padding (fill, setfill)

    69. C++ Stream Input/output Format State Flags internal stream base (ios::dec, ios::oct, ios::hex, ios::showbase)

    73. C++ Stream Input/output Format State Flags Floating-point number; scientific notation (ios::scientific, ios::fixed)

    77. C++ Stream Input/output Format State Flags Uppercase/Lowercase control (ios::uppercase)

    80. C++ Stream Input/output Format State Flags Setting and resetting the format flags (flags, setiosflags, resetiosflags)

    84. C++ Stream Input/output Stream Errors States there are many error member functions in ios eof() failbit fail badbit goodbit good rdstate clear

More Related