This post has been migrated from an old server & blog system. Some things may look strange, such as formatting. Some links and images may be broken. I will try getting around to fixing it ASAP.
At the end of my last OOP344 post, I said I'd be exploring the ncurses.h library a little bit, but my friend Rainulf has already done so on his own blog. He does a good job of explaining some of the functions and data types used in our OOP344 I/O assignment so if you are interested, click here
to check out what he has to say about ncurses!
I have decided to instead explore some of the functions and data types used in conio.h, as it was my responsibility in my group to code the simple I/O functions for the Borland C++ compiler. conio.h is an old library used for console input and output during the MS-DOS days. Here are just a few of the functions and data types declared in the header:
Clears the screen and returns the cursor to its default position (0, 0 or top left corner of console).
[c] struct text_info x;
Structure text_info holds information about the console window, including cursor coordinates, screen width and height (more info
). The gettextinfo function accepts the address of a text_info structure as an argument and then fills that structure with information about the current console window (more info
[c]int key = getch();[/c]
In this example, getch reads a character from the console, and then returns the ASCII code for the character read to the integer named key (windows-specific info on _getch, still applies to the conio version
gotoxy(x, y) does pretty much what its name suggets: moves the cursor to column x, row y on the console. In the example above, the cursor would be moved to column 10 of row 5.
putch(c) will write character c to where the cursor is currently located within the console, and then advance cursor position one column forward (windows-specific info on _putch, still applies to the conio version
cputs(s) will write string s to where the cursor is currently located within the console, and then advance cursor position one column forward (windows-specific info on _putch, still applies to the conio version
For more information about conio.h, check this website