在exe文件中缺少ouptut

时间:2015-06-26 23:38:16

标签: debugging visual-c++

我使用以下C ++代码输入X值,用于打印变量CDF。这个C ++代码应该提供与excel中NORMDIST函数非常相似的值。但是我在调​​试器中得到以下错误,但没有在可执行文件中获取任何输出。有人可以帮忙吗?

#include<iostream>
#include<cmath>
using namespace std;
const double pi = 4.0*atan(1.0);
int main()
{
  const double a1 = 0.319381530, a2 = -0.356563782, a3 = 1.781477937, 
  a4 = -1.821255978, a5 = 1.330274429;
  double X = 0, x = 0; double k = 0;
  double N, CDF, n;
  cout << "Enter the value of the random variable X" << endl;
  cin >> X;
  x = fabs(X);
  k = 1 / (1 + 0.2316419*x);
  n = (1 / sqrt(2 * pi))*exp(-0.5*x*x);
  N = 1 - n*(a1*k + a2*k*k + a3*pow(k, 3) + a4*pow(k, 4) + a5*pow(k, 5));
  CDF = N;
  if (X < 0)
    CDF = 1 - N;
 cin.clear();
 cout << CDF;
 cin.get();
  return 0;
}

我输出的CDF1.exe例如X = 0.7693作为输入,我期待0.7791但是我没有看到CDF1.exe中的任何输出,我在调试器中看到下面的内容。请有人帮助解决问题吗?

'CDF1.exe' (Win32): Loaded 'C:\Users\kdatta\Documents\CQF\C++\CDF1 Debug\CDF1.exe'. Symbols loaded.
'CDF1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'CDF1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'CDF1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'CDF1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Cannot find or open the PDB file.
'CDF1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
The thread 0x4fc0 has exited with code -1073741749 (0xc000004b).
The program '[11216] CDF1.exe' has exited with code -1073741510 (0xc000013a).

1 个答案:

答案 0 :(得分:0)

问题是在调试模式下代码会立即返回,而您却看不到结果。在调试模式下,必须强制程序暂停。你可以放system("pause")

#include<iostream>
int main()
{
  std::cout << "hello world\n";

#ifdef _DEBUG
  system("pause");
#endif

  return 0;
}

PDB文件包含调试信息。这些警告不是错误。尝试通过重建项目来摆脱它们。

另外,点击项目 - &gt;属性,请确保您具有以下设置:

C/C++ -> General -> Program Database for Edit And Continue (/ZI)

Linker -> Debugging -> Generate Debugging Info = Yes