Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 我的cmd输出几乎立即关闭,我似乎不明白为什么_C++_Windows - Fatal编程技术网

C++ 我的cmd输出几乎立即关闭,我似乎不明白为什么

C++ 我的cmd输出几乎立即关闭,我似乎不明白为什么,c++,windows,C++,Windows,这是我的代码,非常简单,仅用于测试 #include <iostream> using namespace std; int main() { int a, b, c; a = 2; b = 7; c = a + b * 3; cout << c; return 0; } 我得到这个调试 'test.exe'Win32:加载了'C:\Users\Jacob\Documents\Visual Studio 2017\Projects\test\De

这是我的代码,非常简单,仅用于测试

 #include <iostream>

 using namespace std;
 int main()
 {
 int a, b, c;
 a = 2;
 b = 7;
 c = a + b * 3;
 cout << c;
 return 0;
 }
我得到这个调试 'test.exe'Win32:加载了'C:\Users\Jacob\Documents\Visual Studio 2017\Projects\test\Debug\test.exe'。已加载符号。 'test.exe'Win32:加载了'C:\Windows\syswow64\ntdll.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\kernel32.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:已卸载'C:\Windows\syswow64\kernel32.dll' 'test.exe'Win32:加载了'C:\Windows\syswow64\kernel32.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\KernelBase.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:已加载'C:\Windows\syswow64\msvcp140d.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\vcruntime140d.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\vcruntime140d.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:已卸载'C:\Windows\syswow64\vcruntime140d.dll' 'test.exe'Win32:加载了'C:\Windows\syswow64\ucrtbased.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\ucrtbased.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:已卸载'C:\Windows\syswow64\ucrtbased.dll' 'test.exe'Win32:加载了'C:\Windows\syswow64\ucrtbased.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:已卸载'C:\Windows\syswow64\ucrtbased.dll' 'test.exe'Win32:加载了'C:\Windows\syswow64\kernel.appcore.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:已加载'C:\Windows\syswow64\msvcrt.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\rpcrt4.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\sspicli.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\cryptbase.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\bcryptprimitives.dll'。找不到或无法打开PDB文件。 'test.exe'Win32:加载了'C:\Windows\syswow64\sechost.dll'。找不到或无法打开PDB文件。 线程0x128已退出,代码为0 0x0。 线程0x1f08已退出,代码为0 0x0。 线程0x15d0已退出,代码为0 0x0。
程序“[1976]test.exe”已退出,代码为0 0x0。

您使用主函数创建的经典C/C++风格程序,没有窗口调用或库,在WIndows中称为控制台程序。这意味着它将在控制台窗口中运行;标准输入和输出将出现在该控制台窗口中

如果您没有控制台窗口,Windows将在程序启动时为您创建一个控制台窗口。但是,当程序结束时,它会立即将其销毁

有很多方法可以解决这个问题。首先是从您已经打开的控制台启动程序-如果没有自动打开,Windows将不会关闭它。但是,如果您试图使用调试器,则这不起作用。第二种方法是让程序在退出前在末尾暂停。您可以通过从cin中读取一些内容来实现这一点,或者按照我在注释中的建议,在程序的末尾放置一个断点


< > VisualStudio输出窗口中看到的消息不是程序的输出,而是Windows本身或C++运行时生成的调试消息。您看到的关于缺少PDB文件的内容是完全无害的,它们意味着您没有Windows提供的DLL的调试信息,这是完全正常的。

在返回0行上放置一个断点。这只是意味着您尚未安装所述库的调试版本;别担心,程序“[1976]test.exe”的最后一行已退出,代码为0 0x0。显示正确完成的所有内容。哦,添加getchar;在返回0之前;这样窗户就不会立即关闭。