Mail Archives: djgpp/1998/01/27/03:15:18
Myknees wrote:
> I hear many people say that, and it makes sense on an abstract level,
> since
> file (or stdin / out) I/O is different from console I/O. But no one
> has ever
> said what concrete bad would really come of it. ...printf("conio &
> stdio can't
> get along\n"); getch();... Will this code run slowly or become
> unstable or be
> less portable or something?
>
> I know this is really a C question, but I'm hankerin' to ask the djgpp
> people
> who say this stuff what they really mean.
The problem with mixing stdio and conio* is that, because they are not
defined within the same standard (in fact, conio is not defined by any
standard, except by example). As such, the behavior that occurs when
they interact is undefined. Theoretically, anything can happen.
Naturally, if you know the precise nature of the interaction between
stdio and conio, then you will be able to use them together -- using the
particular compiler you're using and on the particular platform you're
on. If you switch to another compiler or platform (which naturally
still supports both stdio and conio, otherwise this is a moot point),
then you're back to square one.
And finally, there are possible performance penalties for mixing stdio
and conio. When you come across a situation where two packages think
they're king of the hill, so to speak, and think they have free reign,
using them both (carefully) with one another will undoubtedly result in
some performance penalty -- at the very least, it won't be faster. And
since you're linking in both libraries, your executable is going to be
bigger.
It doesn't make much sense to use _both_ stdio and conio to meet some
programming goal, since they're each intended to be used in their own
right, and not together. After all, if all you want to do is print
something and wait for a keypress, why aren't you using cprintf and
getch (both conio), instead of printf (stdio) and getch (conio), causing
all of these problems in the first place?
.
This stuff applies to any two (or more!) mutually-exclusive I/O
mechanisms; stdio and conio is just an example. It is just as
applicable to, say, stdio and curses.
--
Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
Alcyone Systems / http://www.alcyone.com/max/
San Jose, California, United States / icbm://+37.20.07/-121.53.38
\
"Life may be / the product of imperfections."
/ (Marclo Gleiser)
- Raw text -