Hello Everyone!!
I am new here and this is my first post. I am running Ubuntu 12.04 on my desktop and I am facing a problem compiling my C code (which works perfectly on my Windows Laptop). I tried Hello World program to test it out-
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hello World!!");
getch();
}
Then, I try compiling this code using the following command from terminal-
Code:
gcc -o Output Hello.c
where (as is obvious), I stored the file with the name Hello.c .
I get the following error (copied as is from the terminal)-
Code:
Hello.c:2:18: fatal error: conio.h: No such file or directory
compilation terminated.
It gives the same error when I try-
Code:
g++ -o Output Hello.c
Since this is the simplest of the C programs I have seen, I'm not sure why either of the 2 compilers is not able to work with conio.h . I looked it up in my help file on my Windows laptop and it said that the conio.h header file was not compatible with Unix even when it was compatible with DOS. So, is this the reason I'm not able to compile the code? If yes, then please suggest me some header files which are-
1. Compatible only with GNU/Linux
2. Platform independent
which I can use instead of conio.h and yet get the full functionality of it.
conio.h is the most used header file in C/C++ (more than stdio.h and iostream.h and I haven't seen one of my programs written without it). So even if the header file must change, it must be able to provide the entire functionality of conio.h . I actually didn't expect this when I switched to Linux (which I hear is created entirely in C but I may be wrong). This is a bit of a disappointment for me...
Bookmarks