在Windows 10中编译后没有运行的代码 [英] The code not running after compile in windows 10
问题描述
c ++代码没有运行但是在Visual Studio中编译时没有错误
按下后运行dos窗口打开第二个并关闭
i使用了dev -c ++但是也是同样的问题
我尝试了什么:
i关闭了防病毒软件,但它没有工作
the c++ code not running but it compiled with no error in visual studio
after press run the dos window open for just second and close
i used dev -c++ but also the same problem
What I have tried:
i turned off the antivirus but it didn't work
推荐答案
这有很多原因。当我发生这种事情时我做的是在main函数的第一个语句上设置一个断点,然后在调试器中运行代码并逐步执行它以查看会发生什么。这就是我在这一点上所能提出的建议,因为我看不到你的代码。
There are any number of reasons for this. What I do when this kind of thing happens is I set a breakpoint on the first statement in the main function and then run the code in the debugger and step through it to see what happens. That's all I can advise at this point since I can't see your code.
(狂野猜测)你写了一个控制台应用程序,比如
(Wild guess) You wrote a console application, something like
#include <iostream>
int main()
{
std::cout << "hi there!" << std::endl;
}
在这种情况下,您描述的行为是正确的:应用程序启动,生成输出并(快速)终止。如果你需要有机会看到输出,你必须停止执行(至少暂时)。例如,您可以使用同步输入请求暂停它:
In such a case the behaviour you described is the correct one: the application starts, produces the output and (quickly) terminates. If you need a chance to see the output you have to stop its execution (at least for a while). You can, for instance, pause it with a synchrounous input request:
#include <iostream>
int main()
{
std::cout << "hi there!" << std::endl;
std::cin.get(); // waits for input
}
或者,您可以从命令提示符启动控制台应用程序。
Alternatively, you might launch your console application from the command prompt.
这篇关于在Windows 10中编译后没有运行的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!