我使用了visual studio 2012,这是我第一次使用它。我开始了
NEW → Project-Empty → Project-source 然后 files-add →新项目-Cpp文件并输入以下代码:
#include <iostream>
using namespace std;
int main()
{
int cents;
int dollars, quarters, dimes, nickels, pennies;
cout << "Enter total cents: ";
cin >> cents;
dollars = cents / 100;
cents = cents - dollars*100;
quarters = cents / 25;
cents = cents - quarters*25;
dimes = cents / 10;
cents = cents - dimes*10;
nickels = cents / 5;
cents = cents - nickels*5;
pennies = cents;
cout << "This corresponds to "
<< dollars << " dollars, "
<< quarters << " quarters, "
<< dimes << " dimes, "
<< nickels << " nickels, and "
<< pennies << " pennies.\n\n";
return 0;
}
我想制定一个计划,将美分分为dollars
,quarters
,nickels
,dimes
和pennies
,.exe
窗口成功形成,但在我输入数量后,我想转换窗口消失了。断点或系统(“暂停”)似乎不起作用。这是消息:
'Project2.exe' (Win32): Loaded 'C:\Users\dell\Documents\Visual Studio 2012\Projects\Project2\Debug\Project2.exe'. Symbols loaded. 'Project2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file. 'Project2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file. 'Project2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file. 'Project2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110d.dll'. Symbols loaded. 'Project2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110d.dll'. Symbols loaded. The thread 0xe24 has exited with code -1073741749 (0xc000004b). The program '[7476] Project2.exe' has exited with code -1073741510 (0xc000013a).
如何保留.exe
窗口并查看结果?
答案 0 :(得分:1)
程序中的返回码0xc000013a
表示按下了CTRL-C,导致程序退出。你按CTRL-C了吗?
如果您对分数进行硬编码(例如说1999年),而不是提示用户输入数字,会发生什么?那么它是否正常工作?
如果添加“cin&gt;&gt;美分”,会发生什么? 在 cout语句后显示计算值?
答案 1 :(得分:0)
如果您要编写控制台程序,则应该从控制台运行它们。如果要编写要从GUI运行的程序,请编写GUI程序。
system("pause")
无效的原因是您永远不会cout.flush();
或cout << endl;
。在实际产生输出之前暂停将无济于事。
答案 2 :(得分:0)
使用 ctrl + F5 在没有调试工具的情况下运行程序。