C語言程序中 如何從中間跳出main函數?
#include<stdio.h>main()
{
int y,m,d,s,n,leap=0;
printf("Please input year,month,day:");
scanf("%d%d%d",&y,&m,&d);
if((y%4==0&&y%100!=0)||y%400==0)
leap=1;
switch(m)
{
case 1:s=0;
if(d>31) printf("data error\n"); break;
case 2:s=31;
if(d>29||(d==29&&leap==0)) printf("data error\n"); break;
case 3:s=59; break;
if(d>31) printf("data error\n"); break;
case 4:s=90; break;
if(d>30) printf("data error\n"); break;
case 5:s=120; break;
if(d>31) printf("data error\n"); break;
case 6:s=151; break;
if(d>30) printf("data error\n"); break;
case 7:s=181; break;
if(d>31) printf("data error\n"); break;
case 8:s=212; break;
if(d>31) printf("data error\n"); break;
case 9:s=243; break;
if(d>30) printf("data error\n"); break;
case 10:s=273; break;
if(d>31) printf("data error\n"); break;
case 11:s=304; break;
if(d>30) printf("data error\n"); break;
case 12:s=334; break;
if(d>31) printf("data error\n"); break;
default: printf("data error\n"); break;
}
n=s+d;
if(m>2)
n=n+leap;
printf("%d\n",n);
}
想輸出data error后直接結束整個程序
求解