Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
C++ std::string 堆内存分配的保证?
我的主要目标是避免动态内存分配 例如 我可以确定哪些 std string 方法将 不会分配新的堆内存吗 有没有办法禁止 std string 实例进行新分配 是否有标准的固定长度字符串类 例如 我可以确定哪些 std string 方法将
c
memorymanagement
dynamicmemoryallocation
stdstring
返回字符串及其 .c_str() 的生命周期[重复]
这个问题在这里已经有答案了 我遇到过这种模式的多个实例 仅使用 boost filesystem 作为示例 boost filesystem path path someFunctionTakingCStrings path string
c
string
std
stdstring
C++:指向 std::string 转换的 char 指针是否复制内容?
当我转换一个char to std string使用构造函数 char ps Hello std string str ps 我知道 std 容器在被要求存储值时倾向于复制值 是复制整个字符串还是仅复制指针 如果之后我这样做str Bye
c
string
constructor
stdstring
连接字符串无法按预期工作[关闭]
很难说出这里问的是什么 这个问题是含糊的 模糊的 不完整的 过于宽泛的或修辞性的 无法以目前的形式得到合理的回答 如需帮助澄清此问题以便重新打开 访问帮助中心 help reopen questions 我知道这是一个常见问题 但在寻找参考
c
operatorkeyword
stringconcatenation
stdstring
standardlibrary
在 C++ 中填充 stl 字符串
我在用着std string并需要将它们左填充到给定的宽度 在 C 中执行此操作的推荐方法是什么 输入示例 123 填充至 10 个字符 示例输出 123 123前7个空格 std setw setwidth 操纵器 std cout lt
c
string
padding
stdstring
获取指向成员 std::string::size 的指针无法与 libc++ 链接,但可以与 libstdc++ 一起使用
我正在做一个需要使用 libc 的项目 我遇到了以下问题 当我尝试编译以下代码时 include
c
stdstring
libc
missingsymbols
显式复制构造函数
我扩展了 std string 以满足我的需要 必须将自定义函数构建到名为的字符串类中自定义字符串 我已经定义了构造函数 class CustomString public std string public explicit Custom
c
copyconstructor
assignmentoperator
stdstring
explicit
你能指定 std::getline 中什么不是分隔符吗?
我希望它将任何非字母字符视为分隔符 我怎样才能做到这一点 你不能 默认分隔符是 n while std getline std cin str n is implicit 对于其他分隔符 请传递它们 while std getline st
c
getline
stdstring
malloc 和 calloc 与 std::string 之间的区别
我最近开始接触 C 并且在使用 malloc 时遇到了问题 下面的代码不会打印出 成功 程序崩溃 退出代码为 0xC0000005 而如果我使用 calloc 则一切正常 int main std string pointer std st
c
malloc
stdstring
calloc
如何在 QLineEdit 中使用 std::string ?
我有以下问题 我正在尝试将我编写的大量代码与 Qt 界面集成 我的一些函数返回std string 我没有成功制作QLineEdit setText接受它们 其他函数返回char不要给我带来问题 我应该怎么办 谢谢 朱塞佩 尝试这个 std
c
QT
stdstring
QString
C++ 中的字符串和 int 连接[重复]
这个问题在这里已经有答案了 string words 5 for int i 0 i lt 5 i words i word i for int i 0 i lt 5 i cout lt
c
string
int
concatenation
stdstring
如何从可能包含或不包含 null 的缓冲区构造“std::string”?
我有一个缓冲区 为简单起见 假设是一个固定大小的数组 char我想建造一个std string从 所述缓冲区可以是空终止的或者其内容可以运行到并包括最后一个字符 如果缓冲区确实包含一个或多个空值 它们不应该出现在结果中string 复制应该
c
stdstring
nullterminated
这段代码中的 string::npos 是什么意思?
这句话是什么意思std string npos下面的代码片段是什么意思 found str find str2 if found std string npos std cout lt lt first needle found at lt
c
stdstring
cstandardlibrary
在 gdb 中调用 std::~basic_string()
根据 EvanED 在https stackoverflow com a 11311786 890753我创建了一个gdb命令newstr创建一个新的 std string 并将其放入 gdb 便利变量中 define newstr set
C11
GDB
typeconversion
destructor
stdstring
GCC 4.x / C++11 中 std::string 引用计数吗?
Is std string使用 gcc 4 时进行引用计数 std c 0x or std c 11 看着libstdc 文档我发现 有关更多信息 请参阅链接 一个字符串看起来像这样 Rep M length basic string
c
gcc
C11
stdstring
如何替换字符串中所有出现的字符?
将所有出现的字符替换为另一个字符的有效方法是什么std string std string不包含此类功能 但您可以单独使用replace函数来自algorithm header include
c
Algorithm
strreplace
stdstring
std::string 格式如 sprintf
我必须格式化std string with sprintf并将其发送到文件流中 我怎样才能做到这一点 现代 C 使这变得超级简单 C 20 C 20介绍std format 这使您可以做到这一点 它使用类似于的替换字段那些在Python中
c
string
formatting
stdstring
cstandardlibrary
如何将 CString 和 std::string std::wstring 相互转换?
CString非常方便 同时std string与STL容器更加兼容 我在用hash map 然而 hash map不支持CStrings 作为键 所以我想转换CString into a std string 写一个CString哈希函数
c
MFC
cstrings
stdstring
将 char* 转换为 std::string
我需要使用一个std string存储检索到的数据fgets 为此 我需要转换char 返回值来自fgets 进入一个std string存储在数组中 如何才能做到这一点 std string有一个构造函数 const char s Hel
c
stdstring
错误:“const char [35]”和“const char [2]”类型的操作数对二进制“operator+”无效
在我的文件顶部有 define AGE 42 稍后在文件中我多次使用 ID 包括一些看起来像这样的行 std string name Obama std string str Hello name you are AGE years old
c
string
cpreprocessor
stdstring
«
1
2
3
4
»