

That means the prompt may not display to the user until we manually flush the output stream. But conio functions are direct calls to hardware, and bypass the usual flushing mechanisms. Normally, using getchar or other standard C library input/output functions will cause any printed text to completely display on the screen (this is called flushing the output stream). This version of PAUSE is very short: display a prompt using printf and wait for the user to press a key on the keyboard. Let's re-write PAUSE using conio: #include But in both cases, the user had to press Enter before PAUSE could continue.īy reading the keyboard directly, we can immediately get a keystroke from the keyboard.

We wrote a simple version of PAUSE in part 3 using scanf and in part 4 using getchar.

The FreeDOS PAUSE command displays a prompt, then waits for the user to press a key. You can find the OpenWatcom C library reference (clib.pdf) at the OpenWatcom GitHub site. Instead, I wrote this section using the OpenWatcom C compiler, which is a free C compiler included in FreeDOS. But when I opened the book to reference conio for this series, I found the the IA-16 GCC didn't include many of the conio functions I was familiar with. I still have the C library reference book on my bookshelf. I'll add that I learned conio when I used the Borland C Compiler in the 1990s. For example, while the getch function to get a single character from the keyboard (similar to getchar) exists across many conio implementations, other functions that clear the screen or move the cursor around differ. Every compiler's implementation of conio is a little different, so you need to be careful. Unfortunately, conio is not very portable. The conio library performs console-level input and output. If you want to access the screen directly, including colors and dialog boxes, you need a new library called conio. Writing plain text command-line utilities are great, but eventually you may want to move on from programs that only scroll up from the bottom of the screen. Console programming The nonportability of conio Books | The FreeDOS Project Search Writing FreeDOS Programs in C Part 8.
