请告诉我,我做错了请告诉我,我做错了,因为monthstr2num返回的值是错误
//I'm trying to get the number of the month by sending its name.
#include <stdio.h>
我的功能
int monthstr2num (char month[]){
if (month == "September")
return 8;
}
int main(){
char month []={"September"};
int num;
num = monthstr2num (month);//func call
显示一个错误的输出像37814040
printf ("%d", num);
return 0;
}
你尝试编译代码并启用所有的警告(例如''gcc -Wall -g mehdi.c -o mehdi-prog'?如果你这样做,你应该会得到警告...... –