Mail Archives: djgpp/1996/12/07/03:33:20
Bruce A Locke wrote:
> 
> The ClrScr() command seems to do nothing at all in the program despite
> INFO help stating that it clears the screen.  Also, even if I set the
> textcolor() and textbackground(), The existing screen attributes take
> priority over the colors I set.....
> 
> Does DJGPP handle CONIO differently than in other dos compilers, or am I
> in error?
Try using '-Wall' when you compile; it makes a world of difference when
trying to debug code.  I wish this were the default, because we keep
getting these kinds of questions from people graduating from Borland and
Turbo C.  Anyway...
> #include <conio.h>
You need to also include <pc.h> for the definition of getkey(), and
<stdio.h> for the definition of putchar().  This is caught by -Wall.
> void main(void)
This is a non-ANSI way to declare main().  main() MUST!!! return an int.
>         textcolor(15);
>         textbackground(0);
>         clrscr;
Here is where you would get another warning if you used '-Wall'. 
Specifically:
coniotst.c:26: warning: statement with no effect
What this means is that you should be using:
	clrscr();
Notice the difference?  FYI, the reason "clrscr;" by itself works is
because the name of a function without parentheses serves as a pointer
to that function, so that line is like typing "52;" or "x;" - it's
syntactically valid, but logically meaningless.
Everything else looks okay to me.  Try making these changes and see how
it works.
-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I |        fighteer AT cs DOT com          |
| Proud owner of what might one   |   http://www.cs.com/fighteer    |
| day be a spectacular MUD...     | Plan: To make Bill Gates suffer |
---------------------------------------------------------------------
- Raw text -