Xcode调试器未显示C ++ cout输出 [英] Xcode debugger not showing C++ cout output

查看:190
本文介绍了Xcode调试器未显示C ++ cout输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试学习C ++时,我目前正试图摆脱Xcode中调试器的困扰。我遇到一个问题,调试器没有向控制台显示任何 cout 输出。它只是说 (lldb)

I am currently trying to get the hang of the debugger in Xcode while I am trying to learn C++. I'm coming across a problem where the debugger is not showing any cout output to the console. It just says (lldb)

我已经设置了断点以确保我不会错过任何东西:
4个变量输出

I've set breakpoints to make sure I don't miss anything: 4 variable outputs

如您所见,这段代码已经运行:

As you can see this piece of code has already been run:

int x = 1;
std::cout << x << " ";

但是,控制台仍只向我显示以下内容:
控制台输出

However, the console is still only showing me the following: console output

我可以 跳过 每条语句,除了 (lldb)

I can step over each statement and it still won't show anyting but (lldb)

据我所知,调试器应该依次显示1 2 4 8,因为我 跳过/进入 每条语句。但是,结果仅在我完成调试后才输出到控制台。
本质上我的问题是,为什么我看不到任何显示内容?

To my knowlegde the debugger should be showing 1 2 4 8 sequentially as I step over/step into each statement. However, the results are only output the console after I finish debugging. My question essentially, why am I not seeing anything being displayed?

作为记录,这是我的第一个问题,如果我没有很好地搜索或违反任何规则,请随时让我知道,谢谢。

For the record this is my first question, if I've not searched well enough or broken any rules please feel free to let me know, thanks in advance.

推荐答案

您需要终止输出行,例如:

You need to terminate your output line, e.g.:

std::cout << x << "\n";

std::cout << x << std::endl;

在您写了行终止符后,您的输出应显示出来,如以上任一语句所示。

Your output should show up after your have written a line terminator character as in either of the statements above.

这篇关于Xcode调试器未显示C ++ cout输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆