CodePudding user response:
#include#include
Int main ()
{
Int the month;
Do
{
Printf (" input month (1-12) : ");
Scanf_s (" % d ", & amp; The month);
The switch (month)
{
Case 1:
Printf (" January \ n ");
break;
Case 2:
Printf (" February \ n ");
break;
Case 3:
Printf (" March \ n ");
break;
Case 4:
Printf (" April \ n ");
break;
Case 5:
Printf (" May \ n ");
break;
Case 6:
Printf (" June \ n ");
break;
Case 7:
Printf (" out \ n ");
break;
Case 8:
Printf (" August \ n ");
break;
Case 9:
Printf (" September \ n ");
break;
Case 10:
Printf (" October \ n ");
break;
Case 11:
Printf (" November \ n ");
break;
Case 12:
Printf (" another awarding \ n ");
break;
Default:
Printf (" input in wrong!!!!! \n");
break;
}
} while (getchar ()!='q');
system("pause");
return 0;
}
CodePudding user response:
Two questions, the first: if the input of the month is less than 1 in the main, or more than 12, should prompt input error, and direct return, should not to execute the month function,The second question, return to a local variable is undefined behavior, plus the static modified ~ when amended as defined in the name this name is a global variable,
CodePudding user response:
The name into global variablesCodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.htmlI hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html