Manipulating an output stream
Home Page Parent Page I hate math.

 

Manipulating an output stream

 

If you have read the title, you have no idea what I am talking about. Don't worry, it is suppose to be like that. We are going to revisit the technique of puting output onto the screen the proper way.

When writing to the screen, we are putting data into, an output stream. An output stream is always running in one direction, from the active program to the screen. It is best to think of it as an actual stream, like the Mississippi. The active program, which will probably be yours, is way at the top of the Mississippi in at Saint Louis docks, while the screen is down in New Orleans' port.

When you want to send something down to New Orleans, you send a call to cout which is like a barge. Each barge represents one line on your screen. The cout "barge" then goes down the river to New Orleans, where people can see output. Endl is used to make sure any other data put on the stream will be put into another barge.

So

cout << "Hi there! I am information."<<endl;

would translate to:

"Hi there I am information." being put into a cout barge in Saint Louis, sent down the river with no other information to be put in the barge and then being put on the screen once it hits New Orleans.

Now do you understand what's going on. I hope that is a smile and a nod because there is more stuff to do.

One thing that will probably come in handy is manipulation of the data before it hits Saint Louis. That's right we can change the way things are displayed on the screen.

To be continued....

1