RAD Studio |  |

conio.h
Collapse All

The following functions, macros, and classes are provided in conio.h:

Topics

Name | Description
_setcursortype | Header File conio.h Category Console I/O Routines Prototype void _setcursortype(int cur_t); Description Selects cursor appearance. Sets the cursor type to
cgets | Header File conio.h Category Console I/O Routines Prototype char *cgets(char *str); Description Reads a string from the console. cgets reads a string of characters from the console, storing the string (and the string length) in the location pointed to by str. cgets reads characters until it encounters a carriage-return/linefeed (CR/LF) combination, or until the maximum allowable number of characters have been read. If cgets reads a CR/LF combination, it replaces the combination with a \0 (null terminator) before storing the string. Before cgets is called, set str[0] to the maximum length of the string to be read. On return, str[1]... more
clreol | Header File conio.h Category Console I/O Routines Prototype void clreol(void); Description Clears to end of line in text window. clreol clears all characters from the cursor position to the end of the line within the current text window, without moving the cursor. Note: This function should not be used in Win32 GUI applications. Return Value None. Example
clrscr | Header File conio.h Category Console I/O Routines Prototype void clrscr(void); Description Clears the text-mode window. clrscr clears the current text window and places the cursor in the upper left corner (at position 1,1). Note: Do not use this function in Win32 GUI applications. Return Value None. Example
cprintf | Header File conio.h Category Console I/O Routines Prototype int cprintf(const char *format[, argument, ...]); Description Writes formatted output to the screen. cprintf accepts a series of arguments, applies to each a format specifier contained in the format string pointed to by format, and outputs the formatted data directly to the current text window on the screen. There must be the same number of format specifiers as arguments. For details details on format specifiers, see printf Format Specifiers. The string is written either directly to screen memory or by way of a BIOS call, depending on the value of the global... more
cputs | Header File conio.h Category Console I/O Routines Prototype int cputs(const char *str); Description Writes a string to the screen. cputs writes the null-terminated string str to the current text window. It does not append a newline character. The string is written either directly to screen memory or by way of a BIOS call, depending on the value of the global variable _directvideo. Unlike puts, cputs does not translate linefeed characters (\n) into carriage-return/linefeed character pairs (\r\n). Note: Do not use this function in Win32 GUI applications. Return Value cputs returns the last character printed. Example
cscanf | Header File conio.h Category Console I/O Routines Prototype int cscanf(char *format[, address, ...]); Description Scans and formats input from the console. cscanf scans a series of input fields one character at a time, reading directly from the console. Then each field is formatted according to a format specifier passed to cscanf in the format string pointed to by format. Finally, cscanf stores the formatted input at an address passed to it as an argument following format, and echoes the input directly to the screen. There must be the same number of format specifiers and addresses as there are input fields.... more
delline | Header File conio.h Category Console I/O Routines Prototype void delline(void); Description Deletes line in text window. delline deletes the line containing the cursor and moves all lines below it one line up. delline operates within the currently active text window. Note: Do not use this function in Win32 GUI applications. Return Value None. Example
getch | Header File conio.h Category Console I/O Routines Prototype int getch(void); Description Gets character from keyboard, does not echo to screen. getch reads a single character directly from the keyboard, without echoing to the screen. Note: Do not use this function in Win32 GUI applications. Return Value getch returns the character read from the keyboard. Example
getche | Header File conio.h Category Console I/O Routines Prototype int getche(void); Description Gets character from the keyboard, echoes to screen. getche reads a single character from the keyboard and echoes it to the current text window using direct video or BIOS. Note: Do not use this function in Win32 GUI applications. Return Value getche returns the character read from the keyboard. Example
getpass | Header File conio.h Category Console I/O Routines Prototype char *getpass(const char *prompt); Description Reads a password. getpass reads a password from the system console after prompting with the null-terminated string prompt and disabling the echo. A pointer is returned to a null-terminated string of up to eight characters (not counting the null-terminator). Note: Do not use this function in Win32 GUI applications. Return Value The return value is a pointer to a static string that is overwritten with each call. Example
gettext | Header File conio.h Category Console I/O Routines Prototype int gettext(int left, int top, int right, int bottom, void *destin); Description Copies text from text mode screen to memory. gettext stores the contents of an onscreen text rectangle defined by left, top, right, and bottom into the area of memory pointed to by destin. All coordinates are absolute screen coordinates not window-relative. The upper left corner is (1,1). gettext reads the contents of the rectangle into memory sequentially from left to right and top to bottom. Each position onscreen takes 2 bytes of memory: The first byte is the character in... more
gettextinfo | Header File conio.h Category Console I/O Routines Prototype void gettextinfo(struct text_info *r); Description Gets text mode video information. gettextinfo fills in the text_info structure pointed to by r with the current text video information. The text_info structure is defined in conio.h as follows: struct text_info { unsigned char winleft; /* left window coordinate */ unsigned char wintop; /* top window coordinate */ unsigned char winright; /* right window coordinate */ unsigned char winbottom; /* bottom window coordinate */ unsigned char attribute; /* text attribute */ unsigned char normattr; /* normal attribute */ unsigned char currmode; /* BW40, BW80, C40, C80,... more
gotoxy | Header File conio.h Category Console I/O Routines Prototype void gotoxy(int x, int y); Description Positions cursor in text window. gotoxy moves the cursor to the given position in the current text window. If the coordinates are in any way invalid the call to gotoxy is ignored. An example of this is a call to gotoxy(40,30) when (35,25) is the bottom right position in the window. Neither argument to gotoxy can be zero. Note:Do not use this function in Win32 GUI applications. Return Value None. Example

highvideo
Header File
conio.h
Category
Console I/O Routines
Prototype
void highvideo(void);
Description
Selects high-intensity characters.
highvideo selects high-intensity characters by setting the high-intensity bit of the currently selected foreground color.
This function does not affect any characters currently onscreen, but does affect those displayed by functions (such as cprintf) that perform direct video, text mode output after highvideo is called.
Note: Do not use this function in Win32 GUI applications.
Return Value
None.
Example
insline
Header File
conio.h
Category
Console I/O Routines
Prototype
void insline(void);
Description
Inserts a blank line in the text window.
insline inserts an empty line in the text window at the cursor position using the current text background color. All lines below the empty one move down one line, and the bottom line scrolls off the bottom of the window.
Note: Do not use this function in Win32 GUI applications.
Return Value
None.
Example
kbhit
Header File
conio.h
Category
Console I/O Routines
Prototype
int kbhit(void);
Description
Checks for currently available keystrokes.
kbhit checks to see if a keystroke is currently available. Any available keystrokes can be retrieved with getch or getche.
Note: Do not use this function in Win32 GUI applications.
Return Value
If a keystroke is available, kbhit returns a nonzero value. Otherwise, it returns 0.
Example
lowvideo
Header File
conio.h
Category
Console I/O Routines
Prototype
void lowvideo(void);
Description
Selects low-intensity characters.
lowvideo selects low-intensity characters by clearing the high-intensity bit of the currently selected foreground color.
This function does not affect any characters currently onscreen. It affects only those characters displayed by functions that perform text mode, direct console output after this function is called.
Note: Do not use this function in Win32 GUI applications.
Return Value
None.
Example
movetext
Header File
conio.h
Category
Console I/O Routines
Prototype
int movetext(int left, int top, int right, int bottom, int destleft, int desttop);
Description
Copies text onscreen from one rectangle to another.
movetext copies the contents of the onscreen rectangle defined by left, top, right, and bottom to a new rectangle of the same dimensions. The new rectangle’s upper left corner is position (destleft, desttop).
All coordinates are absolute screen coordinates. Rectangles that overlap are moved correctly.
movetext is a text mode function performing direct video output.
Note:Do not use this function in Win32 GUI applications.
Return Value
On success, movetext... more
normvideo
Header File
conio.h
Category
Console I/O Routines
Prototype
void normvideo(void);
Description
Selects normal-intensity characters.
normvideo selects normal characters by returning the text attribute (foreground and background) to the value it had when the program started.
This function does not affect any characters currently on the screen, only those displayed by functions (such as cprintf) performing direct console output functions after normvideo is called.
Note: Do not use this function in Win32 GUI applications.
Return Value
None.
Example
putch
Header File
conio.h
Category
Console I/O Routines
Prototype
int putch(int c);
Description
Outputs character to screen.
putch outputs the character c to the current text window. It is a text mode function performing direct video output to the console. putch does not translate linefeed characters (\n) into carriage-return/linefeed pairs.
The string is written either directly to screen memory or by way of a BIOS call, depending on the value of the global variable _directvideo.
Note: This function should not be used in Win32 GUI applications.
Return Value
On success, putch returns the character printed, c. On error, it returns EOF.... more
puttext
Header File
conio.h
Category
Console I/O Routines
Prototype
int puttext(int left, int top, int right, int bottom, void *source);
Description
Copies text from memory to the text mode screen.
puttext writes the contents of the memory area pointed to by source out to the onscreen rectangle defined by left, top, right, and bottom.
All coordinates are absolute screen coordinates, not window-relative. The upper left corner is (1,1).
puttext places the contents of a memory area into the defined rectangle sequentially from left to right and top to bottom.
Each position onscreen takes 2 bytes of memory: The first byte is... more
textattr
Header File
conio.h
Category
Console I/O Routines
Prototype
void textattr(int newattr);
Description
Sets text attributes.
Note: Do not use this function in Win32 GUI applications.
textattr lets you set both the foreground and background colors in a single call. (Normally, you set the attributes with textcolor and textbackground.)
This function does not affect any characters currently onscreen; it affects only those characters displayed by functions (such as cprintf) performing text mode, direct video output after this function is called.
The color information is encoded in the newattr parameter as follows:
In this 8-bit newattr parameter:

- bits 0-3 contain the 4-bit... more

textbackground
Header File
conio.h
Category
Console I/O Routines
Prototype
void textbackground(int newcolor);
Description
Selects new text background color.
Note: Do not use this function in Win32 GUI applications.
textbackground selects the background color. This function works for functions that produce output in text mode directly to the screen. newcolor selects the new background color. You can set newcolor to an integer from 0 to 7, or to one of the symbolic constants defined in conio.h. If you use symbolic constants, you must include conio.h.
Once you have called textbackground, all subsequent functions using direct video output (such as cprintf) will use... more
textcolor
Header File
conio.h
Category
Console I/O Routines
Prototype
void textcolor(int newcolor);
Description
Selects new character color in text mode.
Note: Do not use this function in Win32 GUI applications.
textcolor selects the foreground character color. This function works for the console output functions. newcolor selects the new foreground color. You can set newcolor to an integer as given in the table below, or to one of the symbolic constants defined in conio.h. If you use symbolic constants, you must include conio.h.
Once you have called textcolor, all subsequent functions using direct video output (such as cprintf) will use newcolor. textcolor... more
textmode
Header File
conio.h
Category
Console I/O Routines
Prototype
void textmode(int newmode);
Description
Puts screen in text mode.
Note: Do not use this function in Win32 GUI applications.
textmode selects a specific text mode.
You can give the text mode (the argument newmode) by using a symbolic constant from the enumeration type text_modes (defined in conio.h).
The most commonly used text_modes type constants and the modes they specify are given in the following table. Some additional values are defined in conio.h.
ungetch
Header File
conio.h
Category
Console I/O Routines
Prototype
int ungetch(int ch);
Description
Pushes a character back to the keyboard buffer.
Note: Do not use this function in Win32 GUI applications.
ungetch pushes the character ch back to the console, causing ch to be the next character read. The ungetch function fails if it is called more than once before the next read.
Return Value
On success, ungetch returns the character ch.
On error, it returns EOF.
Example
wherex
Header File
conio.h
Category
Console I/O Routines
Prototype
int wherex(void);
Description
Gives horizontal cursor position within window.
Note: Do not use this function in Win32 GUI applications.
wherex returns the x-coordinate of the current cursor position (within the current text window).
Return Value
wherex returns an integer in the range 1 to the number of columns in the current video mode.
Example
wherey
Header File
conio.h
Category
Console I/O Routines
Prototype
int wherey(void);
Description
Gives vertical cursor position within window.
Note: Do not use this function in Win32 GUI applications.
wherey returns the y-coordinate of the current cursor position (within the current text window).
Return Value
wherey returns an integer in the range 1 to the number of rows in the current video mode.
Portability
window
Header File
conio.h
Category
Console I/O Routines
Prototype
void window(int left, int top, int right, int bottom);
Description
Defines active text mode window.
Note: Do not use this function in Win32 GUI applications.
window defines a text window onscreen. If the coordinates are in any way invalid, the call to window is ignored.
left and top are the screen coordinates of the upper left corner of the window.
right and bottom are the screen coordinates of the lower right corner.
The minimum size of the text window is one column by one line. The default window is full screen, with... more

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!