![]() |
VOOZH | about |
The non-standard functions may not come bundled with every C compiler. We may need to install the relevant library manually to use them. Following are some commonly used non-standard Input and Output function in C:
These functions are the part of conio.h library for windows. They are used to read a single character from the keyboard without waiting for a newline.
Syntax
This function does not take any parameters. It returns the ASCII value of the pressed key (as an int). The getch() function does not echo the character to the console, while getche() does.
Example
Output
Press a key (not echoed):
You pressed: E
Press a key (echoed):
E
You pressed:E
The kbhit() function checks if a key has been pressed without blocking. It is also the part of conio.h header file.
Syntax
This function does not take any parameter and return a non-zero if a key is available, zero otherwise.
Example
Output
Press any key to continue, or wait...
Waiting...
Waiting...
Key pressed: f
Also the part of conio.h library, this function is used to clear the console screen. It is exclusive to windows systems.
Syntax
This function neither take any parameter nor returns any value.
Example
Output (Before clrscr())
Screen will clear in 2 seconds...Output (After 2 seconds)
Screen ClearedThe gets_s() is a safer alternative to the deprecated gets, reading a line into a buffer with a size limit. It is optional and is defined inside stdio.h header file if defined.
Syntax
where,
Example
Output
This is input string for testing
Read: This is input string