同样的代码读同样的文件在vc下没问题,跑到vc控制台程序下就不行了
#include "stdafx.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
FILE *stream;
int j;
long pointNum;
double Databuf[480][3]; float err[2];
if( (stream = fopen( "pwm.dat", "r" )) != NULL )
{
for(j=0;j<480;j++)
{
fscanf(stream,"%ld %lf %lf %lf %f %f",&pointNum,&Databuf[j][0],&Databuf[j][1],&Databuf[j][2],&err[0],&err[1]);//异常在这一句
}
}
fclose( stream );
return 0;
}
每行 数字如下
101 -2751.2715 2997.9219 394.1562 -57.7 -58.8
我另写一个文件,
22 22 22
fscanf(stream,"%d %d %d",&a,&b,&c);
好像可以通过,真闹不明白
#include "stdafx.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
FILE *stream;
int j;
long pointNum;
double Databuf[480][3]; float err[2];
if( (stream = fopen( "pwm.dat", "r" )) != NULL )
{
for(j=0;j<480;j++)
{
fscanf(stream,"%ld %lf %lf %lf %f %f",&pointNum,&Databuf[j][0],&Databuf[j][1],&Databuf[j][2],&err[0],&err[1]);//异常在这一句
}
}
fclose( stream );
return 0;
}
每行 数字如下
101 -2751.2715 2997.9219 394.1562 -57.7 -58.8
我另写一个文件,
22 22 22
fscanf(stream,"%d %d %d",&a,&b,&c);
好像可以通过,真闹不明白
double Databuf[480][3]; Databuf放在堆里面试试