This problem required to achieve the function, you can return the English name of a given month.
Function interface definition:
char *getmonth( int n );
Getmonth function should return the string corresponding to n stored the head pointer of the English name of the month. If n is not an argument passed digits for the month, NULL pointer is returned.
Referee test program Example:
#include <stdio.h>
char *getmonth( int n );
int main()
{
int n;
char *s;
scanf("%d", &n);
s = getmonth(n);
if ( s==NULL ) printf("wrong input!\n");
else printf("%s\n", s);
return 0;
}
/* 你的代码将被嵌在这里 */
Sample Input 1:
5
Output Sample 1:
May
Sample Input 2:
15
Output Sample 2:
wrong input!
char *getmonth( int n )
{
static char moth[12][12]={"January","February","March","April","May","June","July","August","September","October","November","December"};
if(n>0&&n<13)
return &moth[n-1][0];
else
return NULL;
}