Use conio. h in linux

Source: Internet
Author: User
Tags nonl
In linux, use conio. h-Linux general technology-Linux programming and kernel information. The following is a detailed description. In fact, there is no conio. h file in linux. To implement functions similar to gotoxy () in BC, you can use curses
# Include
Initialization should be performed before using curses, and injection should be performed after use-these operations call initscr () endwin () respectively to complete.

Main (){
Initscr ();
.
.
.
Endwin ();
}

NOTE: If compilation fails, you can add the-lcurses parameter to introduce the curses library.
Common cureses functions include:
Cbreak ()
Nocbreak ()
Calling cbreak () will read all characters except the output control character (del, ctrl), opposite to nocbreak ()

Nl ()
Nonl ()
Essentially, when you press the Enter key, two characters are generated, one carriage return and one line feed.
If you call nl (), replace the two input characters with "\ n", and replace "\ n" with carriage return and line feed.
Nonl () opposite

Echo () echo
Noecho ()

Keypad (win, bf)
To read the direction key, you must call this function first. curses will convert the direction key to a predefined number, as shown below:
Win is a WINDOW pointer, which is usually passed into the standard screen handle stdscr.
Bf is true | false

KEY_UP 0403 seconds
KEY_DOWN 0402 bytes
KEY_LEFT 0404 rows
KEY_RIGHT 0405 →
KEY_HOME 0406 Home key
(Upward + left arrow) KEY_BACKSPACE 0407 backspace (unreliable)
KEY_F0 0410 Function
Keys. KEY_F (n) (KEY_F0 + (n) Fn
KEY_NPAGE 0522 Next page
KEY_PPAGE 0523 Previous page

Refresh ()
In curses, all output information is not displayed on the screen instantly, but cached. You must use
Refresh () to change the screen. It means that the white point is to display the content in the screen cache to the screen and clear the cache.

Move (y, x)
Getyx (win, y, x) is correct. It's y, x, not & y, & x ---- This is a macro defined in the file.

Clear ()
Erase () should be used in combination with refresh ()

Echochar (c)
Addch (c)
Mvaddch (y, x, c) first move to and then output

Addstr (str)
Mvaddstr (y, x, str)

Printw (format, str) is similar to printf ()
Mvprintw (y, x, format, str)

Int getch ()
Getstr () // this parameter is unknown
Scanw (format, & v1, & v2,...) is similar to scanf ()

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.