我正在尝试从snack.dat 文件中添加信息,但出现此错误。
警告:“fido_speed”可能在此函数中使用未初始化 [-Wuninitialized]|
对于其余的 int* 声明,依此类推。
“小吃.dat”
10 20 5 15
19 20 20 20
1 50 1 51
10 20 10 20
0 0 0 0
代码
int main()
{
FILE* input;
FILE* output;
const char* in_file="snack.dat";
const char* out_file="snack.out";
int* fido_speed;
int* joe_speed;
int* fido_distance;
int* joe_distance;
input = fopen(in_file,"r");
output = fopen(out_file,"w");
while(!feof(input)){
fscanf(input,"%d %d %d %d", joe_distance, fido_distance, joe_speed, fido_speed);
if (((*joe_distance)/(*joe_speed)) < ((*fido_distance)/(*fido_speed))){
fprintf(output,"Fido is no longer hungry.");
}
else if(((*joe_distance)/(*joe_speed)) > ((*fido_distance)/(*fido_speed))){
fprintf(output,"Joe makes it.");
}
else{
fprintf(output,"/0");
}
};
fclose(input);
fclose(output);
return 0;
}