Ask coding questions

← Back to all posts
#include <conio.h> and getch()
Alexander1231 (5)

I am working on an online C course. I am currently working on lectures introducing stacks. However in this lecture I am told to include #include <conio.h> however it will not work on

the second problem I am having is the use of getch() this function also doesn't seem to be working.

Could anyone please help me figure out why these two parts of the code won't work? And how I can fix the problem or even use different headers and functions?

just a side not I have commented out #include <conio.h> in the attached code because the error stopped the code from running.

mwilki7 (1133)

conio.h is a windows header, won't compile on while they use linux OS's
same for the system("cls") command

The linux equivalent would be printing a special character that clears the console screen:


if you wanted to put that in a define:

#define clearScreen() printf("\033[H\033[J")
TheForArkLD (770)

clear not cls
and idk c...

Alexander1231 (5)

@TheForArkLD I am not sure what you mean?

TheForArkLD (770)

cls command for windows.
clear command for linux/unix.

Alexander1231 (5)

@TheForArkLD I am using windows so that means that the clear command is correct?