简体   繁体   中英

How to prevent enter key on windows console from automatically scrolling

Whenever I type some characters into the windows console and hit enter, it automatically scrolls to the next line. Is there any way to disable this behavior in C++ (using the Windows API), and if so; how?

If you call scanf or getline or similar then the underlying C runtime (CRT) handles Enter, Backspace, Delete, arrow keys, Tab, and such, and of course all printable keys.

If you want to handle Enter differently from CRT then you will have to handle every other key as well, using _getch (nonstandard function different from getchar ). You will have to write some code. As far as I know there is no way to use scanf or getline , without Enter going to the next line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM