【发布时间】:2012-09-28 18:50:01
【问题描述】:
请告诉我我做错了什么
//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?如果您这样做了,您应该会收到警告...