错误C2275:"FILE":非法将此类型用作expression_ [英] error C2275: 'FILE' : illegal use of this type as an expression_
问题描述
我的程序是;这是一个mpi程序
my program is;this is a mpi program
并显示此错误(错误C2275:"FILE":将该类型非法用作表达式 )
and show this error (error C2275: 'FILE' : illegal use of this type as an expression )
请帮助我!
int main(int argc,char * argv []){
int i,j;
MPI_Init(& argc,& argv);
MPI_Comm_rank(MPI_COMM_WORLD,& id);
MPI_Comm_size(MPI_COMM_WORLD,& p);
startT = MPI_Wtime();
if(id == MASTER)
{
A =(int *)malloc((r)* sizeof(int));
B =(int *)malloc((s)* sizeof(int));
C =(int *)malloc((r + s)* sizeof(int));
文件* finA;
文件* finB;
finA = fopen("c:/a/resultA.txt","r");
finB = fopen("c:/a/resultB.txt","r");
for(i = 0; i< r; i ++){
fscanf(finA,%d",& A [i]);
}
for(i = 0; i< s; i ++){
fscanf(finB,%d",& B [i]);
}
MPI_Bcast(& A,r,MPI_INT,1,MPI_COMM_WORLD);
MPI_Bcast(& B,s,MPI_INT,1,MPI_COMM_WORLD);
parallel_merge(A,B);
}
stopT = MPI_Wtime();
fclose(fin);
getch();
}
MPI_Finalize();
}
int main(int argc, char *argv[]){
int i,j;
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&id);
MPI_Comm_size(MPI_COMM_WORLD,&p);
startT = MPI_Wtime();
if(id == MASTER)
{
A = (int *)malloc((r)*sizeof(int));
B = (int *)malloc((s)*sizeof(int));
C = (int *)malloc((r+s)*sizeof(int));
FILE *finA;
FILE *finB;
finA=fopen("c:/a/resultA.txt","r");
finB=fopen("c:/a/resultB.txt","r");
for(i=0;i<r;i++){
fscanf(finA,"%d",&A[i]);
}
for(i=0;i<s;i++){
fscanf(finB,"%d",&B[i]);
}
MPI_Bcast(&A,r,MPI_INT,1,MPI_COMM_WORLD);
MPI_Bcast(&B,s,MPI_INT,1,MPI_COMM_WORLD);
parallel_merge(A,B);
}
stopT = MPI_Wtime();
fclose(fin);
getch();
}
MPI_Finalize();
}
推荐答案
请确保您具有: #include< stdio.h>
Make sure you have: #include <stdio.h>
FILE * 是在stdio中定义的-否则,您会得到错误提示.
FILE* is defined in stdio - without this, you'll get errors.
这篇关于错误C2275:"FILE":非法将此类型用作expression_的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!