Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
第一次scanf后崩溃新手c编程_C_Scanf - Fatal编程技术网

第一次scanf后崩溃新手c编程

第一次scanf后崩溃新手c编程,c,scanf,C,Scanf,我的代码() //预处理器指令 #包括 #包括 //主要功能 int main(){ 月、日、年、最低温度、最高温度; 浮子温度; char-fname[30]; 文件*ifp; printf(“告诉我你的龙飞行的首选温度:它们能飞到的最冷温度是多少?\n”); 扫描温度(“%d”,最低温度); printf(“它们能飞到的最热温度是多少?\n”); 扫描温度(“%d”,最高温度); printf(“请输入龙岛天气数据文件的名称。\n”); scanf(“%s”,fname); ifp=fope

我的代码(

//预处理器指令
#包括
#包括
//主要功能
int main(){
月、日、年、最低温度、最高温度;
浮子温度;
char-fname[30];
文件*ifp;
printf(“告诉我你的龙飞行的首选温度:它们能飞到的最冷温度是多少?\n”);
扫描温度(“%d”,最低温度);
printf(“它们能飞到的最热温度是多少?\n”);
扫描温度(“%d”,最高温度);
printf(“请输入龙岛天气数据文件的名称。\n”);
scanf(“%s”,fname);
ifp=fopen(fname,“r”);
fscanf(ifp,“%d%d%f,&month&day&year&temp”);
printf(“%d%d%d%f,&月、日、年和温度”);
返回0;
}
第一次扫描后崩溃无错误

如果你能告诉我错误是什么,我将不胜感激。如果你能帮我解决问题的下一步,那也太棒了

我的任务

%d
需要
int
参数的地址,只需传递
int
变量即可。传递他们的地址-

scanf("%d",&lowest_temp); 
...
scanf("%d",&highest_temp); 
这两种说法-

fscanf(ifp, "%d %d %d %f, &month &day &year &temp");
printf("%d %d %d %f, &month &day &year &temp");   
应该是-

fscanf(ifp, "%d %d %d %f", &month &day &year &temp);
printf("%d %d %d %f", month ,day,year ,temp);  
可能重复的
fscanf(ifp, "%d %d %d %f, &month &day &year &temp");
printf("%d %d %d %f, &month &day &year &temp");   
fscanf(ifp, "%d %d %d %f", &month &day &year &temp);
printf("%d %d %d %f", month ,day,year ,temp);