How do I write my own iosflag?

This is a discussion on How do I write my own iosflag? within the C++ Programming forums, part of the General Programming Boards category; I'm currently working on a program that encrypts and decrypts messages. Traditionally, messages in cryptography are displayed in groups of ...

How do I write my own iosflag?

I'm currently working on a program that encrypts and decrypts messages. Traditionally, messages in cryptography are displayed in groups of five letters regardless of actual spaces. Something like this:

Code:

THISI SONLY ATEST TESTI NGONE TWOTH REE

I know that I could use a loop to put in those spaces, but what I'd really like to do is write my own iosflag. I'd like to display what I just wrote using code like this:

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

Originally posted by master5001 So you are going to have to make a proprietary cout (not that hard).

What do you mean by proprietary? Do you mean that I need to overload the cout operator, or that I should write something like cout, but slightly different and using a different identifier? And, how would I do such a thing? (Just asking for the general syntax form. I don't want anyone to write my program for me.)

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

That is what I mean by proprietary. You can use the same operator. Other than changing cout's definition in the source of your compiler (which isn't always possible, since you may not be using a free compiler) you can't just slap a new identifier in your code and expect cout do know what you mean. You'll need to write your own cout. It could actually use cout for everything except for encryption, which you would have to write yourself. And no, no one is going to write this for you.

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

That looks like a good idea, but my teacher doesn't like it when I include things in my program that he hasn't taught yet, and he hasn't taught classes yet. Really, I'm not even supposed to be using arrays, but he'll just have to live with that

Thanks for all of your help, but I guess I'll just have to settle for something dinky that gets the job done.

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.