strstream

    0热度

    2回答

    我有这样的代码块,写成strstream。我将它转换为sstream如下。我不确定,但我认为printStream->str()正在返回一个字符串对象,其中包含printStream所指向的流缓冲区中的内容的副本(临时),然后您将调用c_str()并获取const char *,然后投射该常量,然后将该指针返回到函数作用域之外。我认为,因为您从printStream->str()得到的临时值,您将

    0热度

    3回答

    我写的代码 #include<sstream> #include<iostream> using namespace std; int main(){ strstream temp; int t =10; temp>>10; string tt ="testing"+temp.str(); 有一个问题,它不会在所有的临时变量上班,就得到结果,而不只是在最后10串测试? }

    3热度

    2回答

    我在清理旧的C/C++应用程序的调试宏时遇到了这个问题:我们有一个Tracer类继承自ostrstream(我知道它自C++ 98以来已被弃用,但是这应用程序写于1998年),我们使用这样的: Tracer() << "some" << " message" << " here"; 现在,如果在链中的第一个值是一个常量字符串像上面,在示踪调用ostrstream::str()(这是在析构函数完

    1热度

    1回答

    我有旧的C++代码使用strstream并使用pcount和冻结方法相同。 我想改为使用stringstream类。什么是strstream的pcount和冻结方法的替代品?该代码是这样的: strstream log; // this will change to: stringstream log; if (log.pcount()) //???? { log << ends;

    -3热度

    1回答

    我希望所有人都知道ostrstream已被弃用,不应在将来使用。 但我的疑问是别的。 我的应用程序的源代码有如下代码。 ostrstream o; o << cell.value(CI) << "-" << cell.value(LAC) << "-" << cell.value(MNC) << "-" << cell.value(MCC) << ends; char* tmp =

    64热度

    4回答

    我最近发现std::strstream已被弃用,支持std::stringstream。自从我使用它以来已经有一段时间了,但它在那时做了我需要做的事情,所以很惊讶听到它的贬低。 我的问题是为什么做出这个决定,并且std::stringstream提供了std::strstream没有的好处?

    2热度

    2回答

    我尝试做以下 std::stringstream str; string string1, string2; long a = 23343; long b = 323234; str << std::hex << a; str >> string1; //line no. 6 str << std::hex << b; str >> string2; //line no.8

    0热度

    1回答

    我正在尝试使用str()读取ostrstream的内容。在尝试这样做时,我总是遇到访问违规和我的应用程序崩溃。有没有办法从strstream中读取而不会导致流错误? 我正在构建Borland C++的遗留项目。我目前正在使用Borland C++ v5.02来构建我的项目。由于代码广泛且分散在大量文件中,因此我无法在此处粘贴代码。不过,我会试着突出我的用例。 ps是在整个项目中用来打印收据的流。我

    1热度

    2回答

    下面的代码编译失败成员: #include <cstdio> #include <sstream> int main() { std::ostrstream strm; strm.rdbuf()->freeze(0); } 我得到编译如下错误: g++ sample3.cpp sample3.cpp: In function 'int mai