Netbeans不显示c++输出
netbeans not showing c++ output
我试着在谷歌搜索结果上阅读了几个不同的帮助论坛结果,但似乎没有一个适用于我的情况。我的Netbeans 8.0.2没有显示任何输出。我有一些程序在函数中有cout而在主程序中有cout。什么都没有。问题是没有返回错误。我不知道你们是否能帮我,但我仍然抱有希望。
OS: Ubuntu 14.04 LTS
Netbean版本:8.0.2
下面是一个示例代码:#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
class calender
{
private:
int month;
int day;
int year;
public:
void getdate(int m, int d, int y);
void showdate();
};
void calender::getdate(int m, int d, int y){
m=month;
d=day;
y=year;
}
void calender::showdate(){
cout<<"The date is:"<<setfill('0')<<setw(2)<<month<<"/"<<setw(2)<<day
<<"/"<<setw(2)<<year<<endl;
}
int main() {
int month, day, year;
char contin;
while (contin=='y'){
calender c1;
cout<<"What is the month: ";
cin>>month;
cout<<"What is the day: ";
cin>>day;
cout<<"What is the year: ";
cin>>year;
c1.getdate(month,day,year);
c1.showdate();
cout<<"Do you want to continue(y/n): ";
cin>>contin;
}
return 0;
}
编辑:我真笨——正如所写的那样,您的代码无论如何都不会有任何输出。您从未初始化变量contin
,因此while
循环中的条件语句永远不会计算为true
。你确定这不是你的问题吗?
相关文章:
- 递归函数计算序列中的平方和(并输出过程)
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 请解释"函数1(p1,p2,p3);"的输出
- C++:将控制台输出存储在宏中更好吗
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- 为什么我的代码在输出中增加了93天
- 如何从void函数输出字符串
- 输入到文件并输出到另一个文件,并将流文件传递给函数
- AES加密到解密未正确输出
- 如何将c++程序的一些输出传递给shell,以便在shell中使用
- 使用C++程序合并排序没有得到正确的输出
- 为什么我不能在不创建字符串变量的情况下使用函数的字符串输出
- C++格式化输出问题
- 将值从二维数组输出到文本文件
- 集合上的输出迭代器:assign和increment迭代器
- 在while循环中输入带有std::cin的字符串后,控制台会输出大量胡言乱语
- 为什么rk4.do_step不输出C++中的初始条件
- 输出没有重复元素的动态数组(收缩数组)C++
- 如何根据单词在文本中出现的概率输出单词