use*_*320 2 c compiler-warnings
所以这是我的代码
int main(int argc, char *argv[] )
{
double mass1, mass2, tof, pixcm;
char pofVfilename[50];
double pix[50];
double pofV[50];
if(argc != 2)
{
printf("usage: %s filename", argv[0]);
}
else
{
FILE *file = fopen(argv[1], "r");
if(file == 0){
printf("could not open file\n");
}
else{
fscanf(file, "%lf %lf", &mass1, &mass2);
fscanf(file, "%lf", &tof);
fscanf(file, "%s", pofVfilename);
fscanf(file, "%lf", &pixcm);
fclose(file);
printf("%lf%lf%lf%lf", mass1, mass2, tof, pixcm);
readinputpofV(pix, pofV, pofVfilename);
printf("%f %f", pix[10], pofV[10]);
}
}
return 0;
}
void readinputpofV(double pix[], double pofV[], char filname[]){
FILE *file = fopen(filname, "r");
if(file == 0){
printf("could not open pofV file\n");
}
else{
int result = 2;
int i = 0;
while(result == 2){
result = fscanf(file, "%lf %lf", &pix[i], &pofV[i]);
i++;
}
}
fclose(file);
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
警告:'readinputpofV'的冲突类型
警告:先前隐含的'readinputpofV'声明就在这里
有人可以帮忙吗 此外,我对文件输入是全新的,并希望对我的工作有一些指导.
这与文件I/O 无关.
试着把void readinputpofV(double pix[], double pofV[], char filname[]);
上面 main().
对函数的调用正在作为它的声明,并且返回类型被假设为int.因此混乱.