implicit calls ??

why the implicit call to EXIT() and clrscr() are marked as error ?

please have a look at my code , and there are errors as per the codechef’s compiler !

#include<stdio.h>

void f1();
void f1()
{
int x;
scanf("\n%d",&x);
if(x!=42)
{
printf("%d\n",x);
{
f1();
}
}
else
{
exit();
}

}

int main()
{

clrscr();
f1();
getch();
return 0;
}

conio.h is not a standard library, so,
you can’t use the functions getch() and clrscr() in the code.

We use getch() in console programs to prevent screen exit,so we can see the output.

We use clrcsr() for clearing the screen.

Now, both these functions are not needed in online judge environment, so, remove them.


Instead of using **exit(0);** just use **return 0;**

Besides, the header file of exit function is missing- < stdlib.h >


To sum up, the corrections to be made are:

  1. Remove getch();

  2. Remove clrscr();

  3. I suggest to use return 0; instead of exit(0);

  4. Also there is no need for \n in scanf("\n%d",&x);, use it as scanf("%d",&x);


I hope that all this should help, if still there is any problem, comment below
1 Like