-3

用 g++ 编译了很多程序后,突然出现了endl;奇怪的行为。除了换行符之外,我还获得了十六进制数字的控制台输出。考虑到我可能有一些内存泄漏问题,我重新启动了在 Windows 之上的 VMWare 中运行的 Linux Mint Debian 版(最新)。问题仍然存在。下面是我的 g++ 版本(与之前的正常输出相比没有变化)和一个输出低于该版本的测试程序。

g++ 版本(Debian 4.8.2-1)4.8.2

void my_test_function(void)
{
  // cout << "my_test_function is working" << cout << endl;
  cout << "my_test_function is working\n" << cout << endl;
}

测试输出:

my_test_function is working 0x600ea8
4

3 回答 3

1

您在声明中有一个不正确的“cout”

尝试关注

void my_test_function(void)
{
  cout << "my_test_function is working" << endl;
}
于 2014-07-23T03:36:07.663 回答
1

我不能在那里发表评论抱歉

该行必须如下所示

cout << "my_test_function is working" << endl;
于 2014-07-23T03:38:25.353 回答
1

固定代码:

cout << "my_test_function is working" << endl;

std::cout是ostream的对象。您需要研究 ostream 的签名operator<<std::cout.

于 2014-07-23T03:43:57.567 回答