软件结束后出现的问题
软件以前运行都是正常的,但是昨天加了一段代码,运行都正常,但是软件一旦结束,退出后就会弹出如下的对话框:
Debug Assertion Failed!
Program:D:\MFC\Debug\test.exe
File:cmdtarg.cpp
Line:52
For information on how your program can cause an assertion
failure,see the Visual C++ documentation on asserts
(Press Retry to debug the application)
添加的代码如下:
double CWinCltView::ADCodeToVoltage(int gain, int polarity, int range, short int temp)
{
double min_voltage, max_voltage;
double scale;
double voltage;
if (polarity==0) /*Bipolar*/
{
if (range==0) /*+-5v*/
{
min_voltage = -5.0;
max_voltage = 5.0;
}
else /*+-10v*/
{
min_voltage = -10.0;
max_voltage = 10.0;
}
}
else /*Unipolar*/
{
min_voltage = 0.0;
max_voltage = 10.0;
}
scale = max_voltage;
if (polarity==0) /*Bipolar*/
{
voltage = ((double)temp / (double)32768)*scale;
}
else /*Unipolar*/
{
voltage = ((double)(temp+32768) / (double)65536)*scale;
}
if (gain>0)
voltage = (voltage / (1 << gain));
return voltage;
}
调用的代码:
float data = (float)ADCodeToVoltage(gain,polarity,range,temp);
我觉得问题不在添加的这段代码上,但是又搞不清楚该如何找到问题的所在,
还请高人指点。