gpt4 book ai didi

c++ - 如何为长字符串分配指针成员?

转载 作者:太空宇宙 更新时间:2023-11-04 15:10:22 25 4
gpt4 key购买 nike

当我进行下面的练习时,删除我的指针成员并为其分配新值。

(*pMyPointer).member.erase();
(*pMyPointer).member.assign("Hello"); // Successfully

比我尝试的更多...

(*pMyPointer).member.erase();
(*pMyPointer).member.assign("Long Multi Lines Format String"); // How to?

如果长多行字符串无法用双引号引用,如何处理。谢谢。

最佳答案

我真的不知道你想问什么。也许是这样的:

(*pMyPointer).member.assign("Long Multi Lines Format String"
"more lines that will be"
"concatenated by the compiler");

或者你的意思是这样的换行符:

(*pMyPointer).member.assign("Long Multi Lines Format String\n"
"more lines that will be\n"
"concatenated by the compiler");

关于c++ - 如何为长字符串分配指针成员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2855214/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com