#include<iostream.h>
#include<conio.h>
#include<process.h>
void function(void);
int main(void)
{
clrscr();
int ch;
while(1)
{
cin>>ch;
if(ch==2)
exit(0);
else
function();
}//while
return 0;
}//main
void function(void)
{
cout<<"Hello";
return;
}
The above code is working fine, but why I'm getting the "unreachable code" warning? I really don't understand what am I doing wrong. The compiler shows no warning when I comment/remove the return 0;
statement in main()
. Why is it so? Please tell me what is it that I'm doing wrong and what is the correct way to do it.