I. Introduction
Conio is short for console input/output (console input/output). It defines functions for data input and output through the console, mainly for operations generated by users by keyboard, for example, the getch () function.
The C compiler on most dos, Windows 3.x, phar lap, dosx, OS/2 or Win32 platforms provides this file. The C compiler on UNIX and Linux platforms usually does not contain this header file.
2. Install and test in Ubuntu
Conio. hNoHeader files in the C standard library. Conio is short for console input/output (console input/output). It defines functions for data input and output through the console, mainly for operations generated by users by keyboard, for example, the getch () function.
Included functions: cgets (char *); cprintf (const char *,...); cputs (const char *); cscanf (const char *,...); indium (unsigned short);
format:String STR: error messageInt matherr (struct exception * E)Function for returning information when a user modifies a mathematical error (not required)Double _ matherr (_ mexcep why, char * Fun, double * arg1p,Double * arg2p, double retval)Function for returning information when a user modifies a mathematical error (not required)
Input and Output subroutines. function libraries include IO. H, conio. H, stat. H, dos. H, stdio. H, and signal. h.
They can conquer who believe they can .--Virgil
CursesIs a UNIX-like systemTerminal control libraryUsed to build the application of the text User Interface [text User Interface (tui )]Program. The name is derived from pun on [cursor optimization ]. It is used to manage applications that use character terminals (character-cell terminals) as interfaces, such as VT100.
Curses-based softwareTypes of Software generally implement the curses library or its compatible Library (such as
flesh-like characters in multiple places on the screen. In this case, you 'd better use Screen Copy to efficiently complete this task. Borland C ++ provides a series of character screen operation functions for these operations.
1. clrscr () clears the character Window FunctionFunction: The clrscr () function clears the entire current character window and marks the light at () in the upper left corner.Usage: This function is called by void clrscr (void );Note: void in brackets indicates no param
of flesh-like characters in multiple places on the screen. In this case, you 'd better use Screen Copy to efficiently complete this task. Borland C ++ provides a series of character screen operation functions for these operations.
1. clrscr () clears the character Window FunctionFunction: The clrscr () function clears the current character window and marks the light at (1, 1) in the upper left corner.Usage: This function is called by void clrscr (void );Note: void in brackets indicates no param
First, these two functions are not functions in the C standard library,
Int getch (void) // read a character from the standard input. When you enter the character on the keyboard, the screen does not display the character you entered. That is, do not bring back the display.Int getche (void) // read one character from the standard input. when entering the keyboard, the screen displays the entered characters. Echo.
These two functions are included in the header file
Two original posts: http://www.cnblogs.com/younes/archive/2010/01/05/1639482.html
Http://blog.csdn.net/cxyol/archive/2006/03/18/628324.aspx
FirstTwo functions are not functions in the c Standard Library:
Int getch (void) // read a character from the standard input. When you enter the character on the keyboard, the screen does not display the character you entered. That is, do not bring back the display.
Int getche (void) // read one character from the standard input. when entering the keyboard,
functions.The difference is that the getchar () function waits for the input to complete all input words before the carriage return is completed until press Enter.Are displayed on the screen one by one. But only the first character is used as the return value of the function.The call format of the getchar () function is:Getchar ()Example 3:# Include Main (){Char CC = getchar ()/reads characters from the keyboard until the carriage return ends/Putchar (C)/display the first character of the Input
getchar () function also reads a character from the keyboard and brings it back to the display. It corresponds to the first two functions.The difference is: The getchar () function waits for the input to end until Press enter. All input words before press ENTERAre displayed on the screen one by one. But only the first character is used as the return value of the function.The call format of the getchar () function is:Getchar ();Example 3:# Include Main (){Char c;C = getchar ();/* read characters
G ++ compile the program to import the getch () function, getch
Note: In ubuntu, G ++ compiles the C ++ program to import the getch () function (the program will continue to run only after a value is input by the standard function, no
C language getch () Problem
Getch (); is not a function in Standard C and does not exist in C .!!Header file: conio. hWe recommend that you replace it with getchar () or another type.Getch ()Getch ():Header file:
The following is a plug-in for executing the Lua script in C language. You can drag the Lua file to the EXE to run it, or bind the 1.lua file in the current directory by default.
Header file and Lua. the location of LIB depends on your own situation, conio. the H header file is only used to allow getch () to read arbitrary characters after each execution and is not displayed. conio can be removed if
Use a clever method to implement the getch () function.
To use the getch () function, you must first introduce the conio. h header file.
However, I use cygwin as the compiling environment and cannot find conio. h. Therefore, I can only find an alternative method or construct a function with similar functions by myself.
Unfortunately, it wasn't long before I learned programming. At the moment, I didn't th
conio. h ). This will inevitably cause a lot of inconvenience to C ++ learners in text interface design and programming. You must know that text interface design is the simplest way to thoroughly learn C ++ and master the implementation method of the interactive system. It is not like the Windows graphic interface application of C ++, too much knowledge is involved. To this end, this series of articles will discuss how to write c ++ applications with
/* 7.13 enter three integers in ascending order (pointers and functions implement switching )*/# Include "stdio. H"# Include "conio. H"Void swap (int * a, int * B, int * C );Void main (){Int x, y, z;Printf ("Enter three integers, Example 1 2 3 \ n ");Scanf ("% d", X, Y, Z );Swap ( X, Y, Z );Printf ("sorted: % d, % d, % d \ n", x, y, z );Getch ();}
void swap (int * a, int * B, int * C) { If (* A> * C) {T = * A; * A = * C; * c = T ;} {T = * A; *
1. pointer # include "stdio. H"
# Include "conio. H"
# Include "string. H"
Void main ()
{
Int I, Radix;
Long N;
Char A [33];
Void trans10_2_8_16 (char * P, long M, int base );
Printf ("\ ninput Radix (2, 8, 16 ):");
Scanf ("% d", Radix );
Printf ("\ ninput a positive integer :");
Scanf ("% lD", N );
Trans10_2_8_16 (A, N, Radix );
For (I = strlen (a)-1; I> = 0; I --)
Printf ("% C", * (a + I ));
Puts ("\ n ");
Getch ();
}
Void trans10_2_8_16 (char *
# Include "stdio. H"
# Include "conio. H"
# Define M 8
Float max (float a [], int N);/** // * function declaration */
Void main ()
{
Clrscr ();
Float sumf, sump;
Float a [m] = {4.5,-3 };
Float (* p) (float a [], INT);/** // * defines the pointer to the function P */
P = max;/** // * function name (function entry address) assigned to pointer p */
Sump = (* p) (a, m);/** // * call a function using a pointer */
Sumf = max (a, m);/** // * use the function
Getch ():
Header file: conio. h
Function purpose: Read a character from the console, but it is not displayed on the screen.
Function prototype: int getch (void)
Returned value: read characters
For example:
Char ch; or Int ch;
Getch (); or CH = getch ();
Use getch (); wait for you to press any key, and then continue to execute the following statement;
Use CH = getch (); after you press any key, assign the ASCII code corresponding to the key
How to Implement the getch () function and the getch FunctionTo use the getch () function, you must first introduce the conio. h header file.
However, I use cygwin as the compiling environment and cannot find conio. h. Therefore, I can only find an alternative method or construct a function with similar functions by myself.
Unfortunately, it wasn't long before I learned programming. At the moment, I didn'
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.