程序在Ubuntu 14.04和GCC中不能正确编译
Program Not Compiling Correctly In Ubuntu 14.04 and GCC
我最近用Ubuntu 14.04 LTS双启动我的Windows PC,我使用Code::Blocks作为我选择的IDE和GCC作为我的编译器。
我是一个学习c++的Java程序员,我写了一个简单的加法程序,取两个数字并将它们相加。当我运行程序时,我输入第一个数字然后第二个数字,而不是告诉我我的答案,它跳过了这个,我只按enter键并结束程序。
下面是我的代码:
#include <iostream>
using namespace std;
int main()
{
int thisisanumber;
int thisisanothernumber;
int outputnumber;
cout<<"Please enter first number: ";
cin>>thisisanumber;
cin.ignore();
cout<<"Please enter second number: ";
cin>>thisisanothernumber;
cin.ignore();
outputnumber = thisisanumber + thisisanothernumber;
cout<<"Your answer is: "<< outputnumber <<"n";
}
听起来好像你在一个程序结束时关闭终端窗口的环境中运行程序。如果你正在使用Code::Blocks,你将需要执行这些步骤。
转到Project -> Properties -> Build targets
确保您的目标是Console project
类型,并且您已经检查了Pause when execution ends
。
相关文章:
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 为什么使用 std::vector 的代码不能编译,但使用 std::unique_ptr 如果没有 noexcept
- 为什么我不能编译这个在Cygwin的Visual Studio中编写的C++文件?
- 为什么我不能编译这个简单的线程测试?
- 为什么 --string::end() 可以编译,而 --string.size() 不能编译?
- 为什么G 5.4不能编译此编译时质数代码
- 为什么最简单的模板模板不能编译
- 为什么这个 c++ 代码不能编译?
- 为什么我不能编译这个开源项目
- 为什么 g++ 不能编译一个简单的 GTK 程序?
- C++。为什么我不能编译此代码?使用const_cast去除恒常性有什么问题?
- 为什么这个模板函数不能编译C++
- 托管类型的成员函数不能编译为非托管函数
- 为什么这个简单的C++程序不能编译?
- 为什么这个C++代码不能编译
- 为什么没有enable_if就不能编译
- 使用重载的operator=不能编译
- CodeRunner——不能编译多个源c++程序
- 为什么[]可变{}不能编译
- 为什么自建的g++编译器不能编译我的代码