Archived

This topic is now archived and is closed to further replies.

Console input and output

This topic is 5151 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What functions are ANSI, work with devc++4, and can do the following in console (for example the windows one)? 1) Get input from the keyboard in realtime (= not like where you have to type something and then press enter, but something that can see what key is pressed while the program is running it's loop) 2) Draw a single character at any location on the screen (including the lowest characters like the smileys 1 and 2) 3) Draw a string of text at any location 4) Put the console into 80x50 mode (instead of the default 80x25) 5) Draw text or characters in color, change foreground and background color, etc... If no ANSI ones exist, do there exist some that work with DevC++4? Thanks! [EDIT] Might it be possible that something is wrong with conio.h in devc++4? [edited by - Boops on November 9, 2003 8:07:08 PM]

Share this post


Link to post
Share on other sites
you can use conio.h or you can use bios.h Under windows I strongly recommend conio.h - note: no unix versions


I know that atleast Borland supports it for windows consoles. I assume the rest should. If they don''t - go and buy a new compiler.

quote:
Original post by Boops
1) Get input from the keyboard in realtime (= not like where you have to type something and then press enter, but something that can see what key is pressed while the program is running it''s loop)

for a loop

char a;
while(!kbhit());
a=getch();

in your program if it constantly loops
char a;
if(kbhit())a=getch();


2) Draw a single character at any location on the screen (including the lowest characters like the smileys 1 and 2)

gotoxy(x,y);
textcolor(c);
then either use
cprintf();
or
putch();

3) Draw a string of text at any location
above - use cprintf

4) Put the console into 80x50 mode (instead of the default 80x25)
textmode(C4350);

5) Draw text or characters in color, change foreground and background color, etc...

textbackground(c);
textcolor(c);





for input, bios.h has ALOT of control over the input. you can get all the other things like shift states and so on, and control the input so you can see whats in the keyboard buffer, and leave them there, take them out, ignore then, and so on.

anyway, have fun.

Share this post


Link to post
Share on other sites
Cool! I found a way to get conio.h to work with devc++ and it''s compiler that wants to be so standard but doesn''t want to support this cool stuff the normal way.

Most of the functions you mentioned are working, except textmode! Is that one from conio.h as well, and in what compiler did you get it to work?

Share this post


Link to post
Share on other sites
quote:
Original post by C-Junkie
And what, pray tell, do you seem to think that ''ANSI'' means, exactly?


By ANSI, I just mean something that is supported by Devc++, since appearantly it''s compiler only wants ANSI things.
Please don''t waste this topic by discussing anything else about ANSI.

Share this post


Link to post
Share on other sites
for text mode;


conio.h


void textmode(int newmode);




Enum: Standard video modes
Constant |Value| Text Mode
----------+-----+----------------------------------
LASTMODE | -1 | Previous text mode
BW40 | 0 | Black and white 40 columns
C40 | 1 | Color 40 columns
BW80 | 2 | Black and white 80 columns
C80 | 3 | Color 80 columns
MONO | 7 | Monochrome 80 columns
C4350 | 64 | EGA and 43-line
| | VGA 50-line


check INSIDE your conio.h file to see if they have textmode() defined. Maybe in the DevC++ compiler they don''t have it in there.


In a standard conio library, it should be in there.

There is another way, I think its using either dos.h or bios.h that lets you use a function like mode(); to change it.

Share this post


Link to post
Share on other sites