stdstring相关内容
如果这样定义一个字符串 std :: string name; 未初始化的字符串“ name”的值是多少,大小是多少? p> 解决方案 由于未初始化,因此被称为默认构造函数。然后: 空字符串构造函数(默认构造函数): 构造一个空字符串,长度为零个字符。 看看: http://www.cplusplus.com/reference
..
我尝试了两种不同的方式将 int 附加到 std :: string ,令我惊讶的是,我得到了不同的结果: #include int main() { std :: string s; s + = 2; //正确编译 s = s + 2; //编译器错误 返回0; } 为什么当我使用 + = 运算符,但是使用 + 运算符会失败吗?
..
在以下代码段中,短语 std :: string :: npos 是什么意思? found = str.find(str2); if(found!= std :: string :: npos) std :: cout
..
如何在C ++中获取字符串中的字符数? 解决方案 如果您使用的是 std :: string ,调用 length() : std :: string str =“你好”; std :: cout
..
在将gcc 4与 -std = c ++ 0x 一起使用时, std :: string 是引用计数的吗? -std = c ++ 11 ? 解决方案 查看 libstdc ++文档(有关更多信息,请参见链接) : 字符串如下: [_Rep] _M_length [basic_string] _M_capacity _M_dataplus _M_re
..
我的问题与在C ++中使用"s"后缀有关? 使用"s"后缀的代码示例: auto hello = "Hello!"s; // a std::string 可以这样写: auto hello = std::string{"Hello!"}; 我能够在网上找到应该使用"s"后缀来最大程度地减少错误并在代码中阐明我们的意图. 因此,使用"s"后缀仅对代码读者有用吗?还是使
..
我在一个需要使用libc ++的项目中.我提出了以下问题: 当我尝试编译以下代码时: #include int main() { std::string::size_type (std::string::*function)() const = &std::string::size; return 0; } 我收到以下错误: ld:架构x86
..
我为什么要通过 std::string::c_str() ?当然,这里有一些解决标准的方法... 解决方案 c_str()保证NUL终止. data()没有.
..
当我使用fans = fans + s[i]时,我的程序之一已超过时间限制,而当我使用fans += s[i]时,它已被接受...为什么会发生这种情况? 为了进一步说明,迷是一个字符串,而s也是一个字符串,因此在遍历字符串si时只需要s的一些字符,所以我创建了一个新的字符串迷.现在有两种方法可以在新字符串中添加字符粉丝.问题在下面提到 fans = fans + s[i]; // gives
..
请帮助我将unicodestring转换为字符串 这就是我得到unicodestring的方式 UnicodeString _str = OpenDialog1->FileName; 或者是否可以使用ifstream或类似的东西写入文件unicode字符串? 谢谢 解决方案 根据您的需要,将UnicodeString分配给AnsiString或UTF8String,然
..
我需要在假设为utf8的std :: string中获取前N个字符的子字符串. 我了解到.substr不能正常工作的困难方式. 参考:我的字符串可能如下所示:任务:\ n \ n1亿2千万匹 解决方案 我std::string utf8_substr(const std::string& str, unsigned int start, unsigned int leng) { if
..
针对 中的讨论 C ++中的跨平台字符串(和Unicode) 如何以跨平台友好的方式处理C/C ++中的Unicode字符串? 我正在尝试将UTF-8字符串分配给Visual Studio 2010环境中的std::string变量 std::string msg = "महसुस"; 但是,当我查看字符串视图调试器时,我只会看到"?????". 我已将文件另存为Uni
..
我今天一直在搜索数小时,但找不到适合我的任何内容.我刚刚看过的一个没有运气的是" 我的问题是,有一个简短的解释: 我想在std C ++中创建有效的NTLM哈希,并且我正在使用OpenSSL的库通过其MD4例程创建哈希.我知道该怎么做,所以有人知道如何将std::string转换为UTF-16 LE编码的字符串,我可以将其传递给MD4函数以获取正确的摘要吗? 所以,我可以有一个保存c
..
我正在阅读“>为什么复制构造函数会有多个参数?. 公认的答案是: 旧的std::basic_string确实也有一个: basic_string(const basic_string& s, size_type pos = 0, size_type n = npos) 但是 http://www.cplusplus.com/reference/string
..
我有一个std :: string,希望第一个字母大写,其余的都小写。 我可以这样做的一种方法是: const std :: string example(“ eXamPLe”); std :: string大写= boost :: to_lower_copy(示例); 大写[0] =大写(大写[0]); 这将产生大写的为: “示例”
..
这是我的代码: #include #include #include 使用命名空间std; int main() { int n; cin>> n; while(n--) { string str; char a [] = {'a','e','i','o','u','A',
..
我对以下代码感到困惑: string _str = "SDFDFSD"; char* pStr = (char*)_str.data(); for (int i = 0; i
..
我有一个定义如下的方法: const std::string returnStringMethod() { std::string myString; // populate myString return myString; } 现在,在呼叫者中,我正在执行以下操作: const char * ptr = returnStringMethod().c_
..
假设,大多数情况下,我有以下替换情况: std::string line; // "line" contains a big string. std::string from = "abcd"; std::string to = "xy"; // to.length()
..
我正在关注C ++教程,并研究字符串和+ =,==,!=等运算符的重载,目前它们具有简单的if语句 if(s1
..