此代码符合你的要求:
#include
#include
#include
int main(){
FILE *fp;
char line[1000];
char wLine[1000];
double SIMUL[100][100];
int lineCount = 0;
char *delim=" ";
int ii,jj;
fp = fopen("1.txt","r");
if( fp==NULL){
printf("fopen error!\n");
return -1;
}
memset(line,0x00,sizeof(line));
while(fgets(line,1000,fp)!=NULL){
strtok(line,delim);
for(ii=0;ii<5;ii++){
SIMUL[lineCount][ii] = atof(strtok(NULL,delim));
}
lineCount++;
}
fclose(fp);
//打印结果
for(ii=0;ii
printf("%f ",SIMUL[ii][jj]);
}
printf("\n");
}
return 0;
}