gpt4 book ai didi

c++ - .exe 窗口退出后

转载 作者:行者123 更新时间:2023-11-28 07:48:05 25 4
gpt4 key购买 nike

我使用的是 visual studio 2012,这是我第一次使用它。我开始了

NEWProject-EmptyProject-source然后files-addnew items -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;
}

我想编写一个程序,将美分分解为 dollarsquartersnickelsdimespennies.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 窗口并查看结果?

最佳答案

程序的返回代码 0xc000013a 表明按下了 CTRL-C,导致程序退出。您是否偶然按下了 CTRL-C?

如果您对美分数进行硬编码(例如 1999),而不是提示用户输入数字,会发生什么情况?那么它能正常工作吗?

如果你添加一个“cin >> cents;”会发生什么? 显示计算值的 cout 语句之后?

关于c++ - .exe 窗口退出后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14449005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com