Jerry Jankura wrote in a message to Mike Walker:
JJ> Mike - Let me offer a few advantages of stream I/O
JJ> 1. The same symbols (">") or function names are used to
JJ> read from, or write to any kind of device (console, file, or
JJ> in-core storage). With stdio, you have to remember to use
JJ> printf, sprintf, or fprintf depending on what kind of device you
JJ> are writing to.
The notation looks a little strange at first. Expecially for someone not used
to C++ yet. :-) Can you tell me what you mean by "in-core" storage? Are you
refering to writting to memory?
JJ> 2. Stream I/O is extensible, standard I/O is not. For example, you
JJ> can write your own operator "<<" to write the contents of an
JJ> instance of a structure; you cannot reasonably modify printf()
JJ> to write the contents in the same manner.
So then if I was displaying a user defined record of some kind I could extend
cout to display/store my record type? This sounds pretty pretty neat, I'll
have to look into this a little.
JJ> 3. Stream I/O is parsed at compile time, stdio is parsed at run
JJ> time. This means that stream I/O can potentially be smaller and
Really I did not realize the stdio was parsed at run time. This would be a
definate plus for stream io wouldn't it?
JJ> 4. If you're willing to derive objects from streambuf and iostream,
JJ> you can build your own devices (perhaps a "modem" or an "ascii
I think this will have to wait since I am still learning the basics of C++. I
am finding that there are a lot of similarities to object pascal that I was
writting. It would be interesting to derive an object for the modem device. I
could really see a lot of potential use for an object such as this. It would
be pretty useful for writting doors, or even a bbs package for that matter.
JJ> Other than being able to work with legacy programs written in C,
JJ> (There, I was finally able to use the term "legacy" in connection
JJ> with C and C++ :), I can't think of any inherent advantage of stdio
JJ> over stream I/O.
I'm not too worried out this since I am making the transition from pascal to
C++. C really isn't much of an issue here since I am making the move to C++
not C.
Mike....
--- timEd 1.10+
---------------
* Origin: Arcadia [New Westminster, BC] (1:153/831.4)
|