从main返回0会中断我的程序
Returning zero from main breaks my program
我刚开始学习c++,主要方法是:
#include <iostream>
using namespace std;
int main ()
{
int d;
int n;
cout <<"Enter the denominator: " << endl;
cin >> d;
cout <<"Enter the numerator: " << endl;
cin >> n;
cout <<"The result of operation is: " << endl;
cout << (double)n/d << endl;
cout <<"Done";
return 0;
}
它不产生输出,但如果我删除返回0。我将生成正确的输出。c++中的main方法最终不应该总是返回一个整数吗?
返回前尝试cout.flush();
。它强制将缓冲的数据发送到输出。
我看了你的代码,一切似乎都是正确的。当我运行它时,它工作得很好。如果你还没有解决它,试着把你的代码放到一个新项目中。我知道这听起来很愚蠢,但它应该工作。
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- 我的代码运行良好,但在游戏循环中中断
- 为什么当我输入一个被接受的数字时,我的 do-while 循环没有中断?
- 为什么我的 while 循环对于特定输入中断,而对于其他输入工作正常?
- 为什么我的代码在第一个 if 语句处中断?
- 为什么我的中断被调用,但不会进入处理程序?
- 我的 break 语句没有中断 for 循环
- 似乎诅咒导致我的循环提前中断
- 为什么我的STM32F7仅每43秒中断一次
- Delete[]数组中断了我的C++程序
- 调用delete[]会中断我的C++程序
- C++代码中断行,为了我的爱,我无法修复它
- 超级基本代码:为什么我的循环没有中断
- C++ 为什么我的循环中断了
- 我的中断例程无法正确访问数组
- 不断收到处理错误.导致我的程序中断
- 从main返回0会中断我的程序
- Pageheap 不会使我的应用程序中断
- 我可以在不中断代码的情况下删除此警告吗?
- 我的程序是否因为在一个线程中使用new而在另一个线程中使用delete而被中断?