stdstring

    0热度

    1回答

    #include <iostream> #include <cstring> using namespace std; const char * substringAfterLast(const char * str, const char * separator) { if (str == NULL) { return NULL; } els

    1热度

    1回答

    我有一个带有两个项目的VS 2010 C++解决方案,一个生成一个DLL,另一个生成DLL函数的驱动程序。以下全部代码 char cstring [256]; strcpy (cstring, "C String"); std::string string1 = "Test String"; std::string string2 (string1); std::string string

    -3热度

    3回答

    基本上,我试图通过消除在字符串s中输入的所有数字来打印字符串。但字符串c不打印。另外c.empty()给出了一个真正的值。为什么会发生这种情况,以及如何解决? #include<iostream> #include<string> #include<cctype> using namespace std; int main() { string s; string c

    0热度

    2回答

    我有一个函数,返回std::string。我将它传递给printf,并创建了一个帮助函数,该函数使用通用参数调用该函数,并返回std::string中的c字符串指针。每次通话都会收到相同的指针。我认为这与临时性的生活有关。如果可能的话,我想解决这个问题并使其安全。 #include <stdio.h> #include <string> std::string intToString(int

    1热度

    1回答

    我在Visual Studio 2005和2008下使用了一段简单的char缓冲区。 我今天转换为VS 2013,并且在不同的场景中出现模糊的转换错误。我删除了不需要的部分代码: #include <string> class ACP { public: ACP(const char* const init) : ourStr_(_strdup(init)), size_(str

    0热度

    2回答

    我使用std::string很多,但我使用的各种库以const char*为参数。我很疑惑std::string没有转换运算符到const char*。所以我正在寻找一些方法,无需在我的项目中始终调用c_str()。 有没有办法?

    0热度

    1回答

    我正在考虑在我们的项目中提出以下作为sprintf/snprintf的替代方案。 其动机是消除考虑缓冲区大小的需要,并尽可能地保留原始的便利性。 std::string strprintf(const char *fromat, ...) { std::string s; s.resize(128); // best guess char *buff = const

    2热度

    3回答

    好的,所以我正在用C++编写一个家庭作业项目,并且遇到了一个问题,似乎无法找到解决方法。该函数应该在用户定义的分隔符处破坏输入字符串,并将子字符串存储在一个向量中以便稍后访问。我想我得到了基本的解析器,但它不想分割输入的最后部分。 int main() { string input = "comma-delim-delim&delim-delim"; vector<string

    1热度

    1回答

    使用CString.Format(),我传递一个std::map给予int时返回std::string。 所以: CString cStr; cStr.Format("%s", IntToStdStringMap[1]); 其中IntToStdStringMap[1]返回一些字符串,我们会说 “你好,世界!”。问题是这似乎并不是每次都会崩溃。最终,我会收到访问违规。 为什么会这样呢? 请记住

    0热度

    2回答

    内存泄漏在Linux机器上,运行此脚本来编译一个小的C++应用程序,并在Valgrind的运行它: #!/bin/bash set -x -e cd /tmp cat > main.cpp <<EOF #include <stdlib.h> // exit() #include <string> // std::string int main(int argc, char *ar