字符串类问题

以下两个函数提供了用指针引用字符串的方法

char *GetMonthName1(int n)
{
    static char *MonthName[]={"ERROR","Jan.","Feb.","March.","Apr.","May.","June.","July.","Agu.","Sept.","Oct.","Nov.","Dec."};
    if(n<1||n>12) return MonthName[0];
    else return MonthName[n];
}

char *GetMonthName2(int n)
{
    static char *MonthName[]={"ERROR","Jan.","Feb.","March.","Apr.","May.","June.","July.","Agu.","Sept.","Oct.","Nov.","Dec."};
    char **ppName=&MonthName[0];
    if(n>12||n<1) return *ppName;
    else return *(ppName+n);
}

你可能感兴趣的:(字符串类问题)