【发布时间】:2015-07-20 08:04:37
【问题描述】:
我的 C++ 代码编译并运行,但没有输出输出到控制台。我认为这与字符串变量有关,但我不确定。我是个菜鸟,任何帮助将不胜感激。我正在使用带有 GNU GCC 编译器的代码块。
#include <iostream>
#include <string>
using namespace std;
int main()
{
string botlong, botshort, secondline;
botlong = "bottles of beer on the wall,";
botshort = "bottles of beer";
secondline = "Take one down and pass it around,";
for(int bottles = 99; bottles<=0; bottles--)
{
cout<<bottles <<botlong <<bottles <<botshort;
for(int lostB = 98; lostB<=0; lostB--)
{
cout<<secondline<<lostB<<botlong;
}
}
return 0;
};
【问题讨论】:
-
您是否尝试添加
endl以查看一些结果? -
嗯。尝试在字符串中添加新行?喜欢做'
-
@alifirat 是对的,您应该在程序结束前
flush流(或任何流)。
标签: c++ gcc codeblocks gnu