4. Function "Exit" should have a prototype Error

 Code:

#include<stdio.h>
#include<conio.h>
void main()
{
 int a;
 while(1)
 {
   printf("1.Menu\n2.exit");
   printf("\nEnter your choice::");
   scanf("%d",&a);
   switch(a)
   {
    case 1:printf("\nYour choice is Menu");
    break;
    case 2:exit(0);
   }
   getch();
 }
}




Error: Function exit() should have a prototype
  • This type error occur due to missing library file.
  •  So just add header file #include<stdlib.h>  in above program.
  • Run  again program in turbo c++ and see output.

Note : Here we need compulsory add header file for standard library for use exit function.      

0 comments: