How to include conio.h

Started by againagain, October 11, 2011, 07:23:09 PM

Previous topic - Next topic

againagain

Some years ago we used a different environment and constantly called functions from the conio library. Only afterwards did I learn that it wasn't standard and that a lot of environments don't support it.

Thing is, I tried running a couple of those old programs in Pelles C, and sure enough, I get "missing prototype" errors for all of conio's functions (textbackground, getch, gotoxy...) despite having included <conio.h>, and despite conio.h being there in the PellesC\Include folder. I really don't know how to manage libraries; is there a way I could use conio?

Vortex

#1
Hi againagain,

The standart #include <conio.h>  statement should work. What's exactly the error message returned by Pelles C IDE?

This example is tested with Pelles C:



#include <stdio.h>
#include <conio.h>
int main(int argc,char *argv[])
{
_clrscr(); /*declared in conio.h*/
printf("Hello world!");

}
Code it... That's all...

CommonTater

You probably need to go into Project->Settings->Compiler and check "Define Compatibility Names".

All the functions in conio are non-standard so they will be prefixed by an underscore... checking the box allows the compiler to see them without the underscore.

Also #include <conio.h>

againagain

Quote from: CommonTater on October 11, 2011, 08:15:58 PMAll the functions in conio are non-standard so they will be prefixed by an underscore... checking the box allows the compiler to see them without the underscore.

That seemed to do the trick, thanks :D Didn't know about underscore for nonstandard functions.

CommonTater

#4
Look in the help file (that's why it's there afterall) and you will discover that every function in the library is listed and the non-standard ones are clearly identified... both with ugly purple text at the top of their pages but also with an underscore before their names. 

Of course, in an ideal world, you should not use non-standard fuctions...
(But there's nothing ideal about this world, far as I can tell  ;D )