这样变化的字符串如何初始化啊
各位大侠,我想请问怎么初始化一个变化的字符串啊。。我想定义一个字符串a[6],如果它等于“-Feb-”,就输出2,如果它等于“-Jan-”,就输出1
#include <stdio.h> #include <string.h> main() { int i; char a[12][4]={"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"}; char b[4]; gets(b); for(i=0;i<12;i++) if(!strcmp(a[i],b)) printf("%d\n",i+1); }