Skip to content
← Back to Community
#include <conio.h> and getch()
Profile icon
Alexander1231

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 repl.it.

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.

Voters
Profile icon
052alfannoor
Profile icon
talalkanjo
Profile icon
Xzoky645
Profile icon
Marcovski
Profile icon
AaryanAnsh
Profile icon
Alexander1231
Comments
hotnewtop
Profile icon
mwilki7

conio.h is a windows header, won't compile on repl.it 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:

printf("\033[H\033[J");

if you wanted to put that in a define:

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

clear not cls
and idk c...

Profile icon
Alexander1231

@TheForArkLD I am not sure what you mean?

Profile icon
TheForArkLD

@Alexander1231
3F886386-7ADE-4843-9710-E337E3DF292D

Profile icon
TheForArkLD

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

Profile icon
Alexander1231

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

Profile icon
TheForArkLD
Profile icon
TheForArkLD

@Alexander1231 repl.it is using linux