prototype of a function in c++ is mandatory to give.........but when we give the prototype of the function then there are alot of errors.....
see ex
int printf(const char*,...);
int scanf(const cahr*,...);
int kbhit(void);
void clrscr(void);
int main(void)
{
clrscr();
printf("hello");
while(!kbhit());
return 0;
}
file extension must be .cpp
when file extension is .c or any extension except .cpp then this program gives output hello......
#ifdef __cplusplus
extern"C" {
#endif
int printf(constchar*,...);
int scanf(constchar*,...);
int kbhit(void);
void clrscr(void);
#ifdef __cplusplus
}
#endif
int main(void)
{
clrscr();
printf("hello");
while(!kbhit());
return 0;
}
But usually you just include the function defs in stdio.h, stdlib.h, and (in your case) conio.h, which do the extern "C" for you.
Andy
P.S. The C++ compiler mangles (or decorates) names unless you tell it they're C names. And printf() etc are C names from a C library. The mangling is compiler specific and is based on the parameters types, etc. e.g. VC++ mangles int __cdecl printf(charconst *,...) to ?printf@@YAHPBDZZ