Visual C ++ programming course by Paul Elias

Visual C ++ programming course by Paul Elias

Author:Paul, Elias [Paul, Elias]
Language: eng
Format: epub
Published: 2020-06-19T16:00:00+00:00


Introduction

Almost all high-level languages have standard libraries of functions for manage data input / output, both for keyboard / screen and files. C ++ does not uses this strategy, that is, it does not define a function library, but rather defines a class library that can be expanded and improved if the application requires it.

The idea is that the input and output operations are applied to objects of some classes determined, using operator overload as a method to indicate the form of enter and extract data to or from I / O to our program.

The way of working with I / O makes it possible to check input and output types, that we have a uniform way of reading and writing variables of all types (including classes) and even that we can treat in a similar way the input output for different devices.

The fundamental concept in C ++ for dealing with input / output is the notion of stream that is can translate as flow or stream. The idea is that there is a flow of data between our program and the exterior, and the streams are in charge of transporting the information, will be as a channel through which we send and receive information.

C ++ defines streams to manage keyboard and display I / O (standard input and output), the File I / O and even character string I / O management.

First we will study the I / O between us and the machine (keyboard and screen) and then we will see the file and chain management. We'll talk about simple input and output first, and then We will discuss the formatting possibilities and the use of I / O handlers.

Stream objects

C ++ defines (by including the header ) a series of stream classes , the most They are important istream , ostream and iostream defining streams input, output and input / output respectively. In addition to defining the classes, in this header a series of standard objects that will be the ones we will use most frequently: cin Object that receives input by keyboard, belongs to the istream class cout Object that generates the screen output, belongs to ostream cerr Object for error output, is an ostream that initially outputs its messages per screen, although you can redirect.

clog Same as cerr , but manages buffers differently

Input and output

At this point we will describe the ios class, which is the class used to define objects of type stream to handle I / O. First we will see the class description and then we will see that things we can use to know the status of the stream, the I / O formatting possibilities and a list of special Streaming access features.

The ios class

class ios {

ostream * tie (ostream * s); // Link two streams

// we can link input with output

76

Page 83

ostream * tie ();

int width (int w);

// Set the field length

int width () const;

// Returns the length

char fill (char);

// Set padding character

char fill () const;

// Returns padding character

long flags



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.