我想更舒适地使用cout

发布于 2025-01-27 02:51:52 字数 381 浏览 2 评论 0原文

我想使用cout打印出此句子:“您可以构建Piramid哪个地板只有奇怪的。就像下面的方式一样。但是,当我使用这种方式时,会发生错误。那么,有什么方法可以这样使用吗?

cout << "You can build piramid which floor is only odd.
        not even" << '\n';

image

I want to use cout to print out this sentence: "You can build piramid which floor is only odd. not even", but I want to do it more comfortably. Just like the way below. But, when I use this way, an error occurs. So, is there any way to use it like this?

cout << "You can build piramid which floor is only odd.
        not even" << '\n';

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最近可好 2025-02-03 02:51:52

相邻字符串文字即使它们在不同的行上,也会自动兼容。因此,您可以这样写它:

std::cout << "You can only build pyramids whose floor is odd, "
             "not even.\n";

Adjacent string literals will automatically be concatenated, even if they are on different lines. So you can write it this way instead:

std::cout << "You can only build pyramids whose floor is odd, "
             "not even.\n";
雄赳赳气昂昂 2025-02-03 02:51:52

要在C ++中使用多行字符串,您 can 使用Backsslash。

 cout << "You can build piramid which floor is only odd. \
not even" << '\n';

To use multi-line strings in C++, you can use backslash.

 cout << "You can build piramid which floor is only odd. \
not even" << '\n';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文