类似于打印END<<结束;在C ++? [英] Something like print END << END; in C++?

查看:164
本文介绍了类似于打印END<<结束;在C ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法像PHP一样?

  print<< END 
yadayadayada
END;

在C ++中? (多行,非转义,易于剪切和粘贴的数据流插入)

解决方案

现在已经过时了现代的C ++ - 请参阅 sbi的回答为现代的方式。



这是你可以做的最好的:

  std :: cout<< 
这是一个
multiline \\\

string.\\\
;

不如正确的heredoc方便,但并不可怕。

Is there anyway to do something like PHP's

print << END
yadayadayada
END;

in C++? (multi-line, unescaped, easy-to-cut-and-paste stream insertion)

解决方案

This answer is now out of date for modern C++ - see sbi's answer for the modern way.

This is the best you can do:

std::cout <<
    "This is a\n"
    "multiline\n"
    "string.\n";

Not as convenient as a proper heredoc, but not terrible.

这篇关于类似于打印END&lt;&lt;结束;在C ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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