错误为:
Unhandled exception in PP.exe:0xC0000005:Access Violation
选择“否”进入调试
程序转向
float u=*(u1)*dyzy;// 具体出错地方
查看u1变量的数据:
CXX0030:Error:expression cannot be evaluated.可奇怪的是,我这个程序是执行一段时间后才出的错,我修改过ONE_MILLI_SECOND 和TIMER_ACCURACY的值,还是出错,奇怪的是
每次出错时bb=15433,而且bb>15433都有错。
下面是程序段,由于程序很长,我只选了感觉能够说明问题的片段。
谢谢。//定义1ms时钟间隔,以ms为单位
# define ONE_MILLI_SECOND 30
//定义时钟分辨率,以ms为单位
# define TIMER_ACCURACY 1 #define MAX_PARA 30720void CPPView::OnStart()
{
//开启多媒体定时器
TimerID1_1ms = timeSetEvent(wTimerRes_1ms, wAccuracy,
(LPTIMECALLBACK) OneMilliSecondProc2,
(DWORD)this,TIME_PERIODIC);
}
void PASCAL OneMilliSecondProc2(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2)
{
int i=0;
float data[MAX_PARA];
for (i=0;i<MAX_PARA;i++)
{
srand((unsigned int)time(0));
data[i]=(rand()%100)/1000000.0f+((2*rand()-2*rand())%50001)/10000.0f;
} temp1=data;
for(int bb=0;bb<long(gulConvNum/4);bb++)
{
p=pointidentify((FLOAT far *)(temp1)+bb*2); //调用函数出错
...
}
}
float pointidentify(float u1[])
{
double zhi1,zhi2,zhi3,zhi4,zhii1,zhii2,zhiu1,zhiu2;
double p1=0; float u=*(u1)*dyzy;// 具体出错地方,
float i=*(u1+1)*dlzy;
...
}
Unhandled exception in PP.exe:0xC0000005:Access Violation
选择“否”进入调试
程序转向
float u=*(u1)*dyzy;// 具体出错地方
查看u1变量的数据:
CXX0030:Error:expression cannot be evaluated.可奇怪的是,我这个程序是执行一段时间后才出的错,我修改过ONE_MILLI_SECOND 和TIMER_ACCURACY的值,还是出错,奇怪的是
每次出错时bb=15433,而且bb>15433都有错。
下面是程序段,由于程序很长,我只选了感觉能够说明问题的片段。
谢谢。//定义1ms时钟间隔,以ms为单位
# define ONE_MILLI_SECOND 30
//定义时钟分辨率,以ms为单位
# define TIMER_ACCURACY 1 #define MAX_PARA 30720void CPPView::OnStart()
{
//开启多媒体定时器
TimerID1_1ms = timeSetEvent(wTimerRes_1ms, wAccuracy,
(LPTIMECALLBACK) OneMilliSecondProc2,
(DWORD)this,TIME_PERIODIC);
}
void PASCAL OneMilliSecondProc2(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2)
{
int i=0;
float data[MAX_PARA];
for (i=0;i<MAX_PARA;i++)
{
srand((unsigned int)time(0));
data[i]=(rand()%100)/1000000.0f+((2*rand()-2*rand())%50001)/10000.0f;
} temp1=data;
for(int bb=0;bb<long(gulConvNum/4);bb++)
{
p=pointidentify((FLOAT far *)(temp1)+bb*2); //调用函数出错
...
}
}
float pointidentify(float u1[])
{
double zhi1,zhi2,zhi3,zhi4,zhii1,zhii2,zhiu1,zhiu2;
double p1=0; float u=*(u1)*dyzy;// 具体出错地方,
float i=*(u1+1)*dlzy;
...
}
不知道你的bb*2到底是何用意。
放在循环里也错了。
bb*2是数组中含两种值,电压值,电流值,交替出现,每个都是30720个srand((unsigned int)time(0));
放在循环里也错了。
为什么?