最近在学习obj-c,按照书上的例子输完以后,运行ok,这个例子要用scanf读取键盘输入一个数字,但敲完数字后回车,没有显示运行后的结果,之前的一个例子也是这样
//打印每月的天数 int main (int argc, char *argv[]) { @autoreleasepool { enum month { january = 1, february, march, april, may, june, july, august, september, october, november, december }; enum month amonth; int days;
NSLog(@"Enter month number: ");
scanf("%i", &amonth);
switch (amonth)
{
case january:
case march:
case may:
case july:
case august:
case october:
case december:
days = 31;
break;
case april:
case june:
case september:
case november:
days = 30;
break;
case february:
days = 28;
break;
default:
NSLog(@"bad month number");
days = 0;
break;
}
if (days != 0)
NSLog(@"Number of days is %i", days);
if (amonth == february)
{
NSLog(@"...or 29 if it's a leap year");
}
}
return 0;
}