Questions tagged [ostringstream]

Output stream class to operate on strings.

150 questions
1
vote
1 answer

Convert double to string quickly observing given precision

I have a C++ program using SDL. During rendering, I need to draw some graphics components. I sometimes need to convert double variables, rounded to one decimal, to std::string. For this, I'm currently using a ostringstream object and it works…
Grégoire Borel
  • 1,880
  • 3
  • 33
  • 55
1
vote
2 answers

C++ - Corrupted String

I'm quite new to C++, but I'm used to some coding with R language. I started, a few weeks ago, to put together a small application that should copy and rename file pairs (.seq/.ab1). Result from a DNA sequencer analysis (renaming hundreds of them…
Rodrigo
  • 155
  • 1
  • 11
1
vote
0 answers

Using >> operator stop my stringstream to get chars from a file stream

//I know it is bad using (namespace std) but I'm editing a "attached project" // as exercise from my Professor. //All required libraries: iostream, fstream, sstream, stdlib are included. stringstream stringas; ifstream fromfile; …
Simon T04D
  • 11
  • 4
1
vote
2 answers

basic_stringbuf has no member named 'freeze'

The following code fails to compile: #include #include int main() { std::ostrstream strm; strm.rdbuf()->freeze(0); } I get the following errors on compilation: g++…
pankaj kushwaha
  • 369
  • 5
  • 20
1
vote
2 answers

Output a ostringstream to file

I currently do this to write the contents of an ostringstream to a file: ... // -- Loop 1 Start std::ostringstream osStr; ... // -- Loop 2 Start cv::string s(osStr.str()); std::istringstream iss(s); cv::vector subVec; …
fakeaccount
  • 933
  • 4
  • 13
  • 23
1
vote
2 answers

c++ extract just numbers from an ostringstream

If I have an ostringstream that contains various numbers separated by - (That's: space - space btw) Could I extract each number individually?
fakeaccount
  • 933
  • 4
  • 13
  • 23
1
vote
2 answers

Redirect from a std::ostringstream to another std::ostringstream

I need write data from some std::ostringstream to another std::ostringstream. Of course, I can use str() function std::ostringstream in; std::ostringstream out; in << "just a test"; // it's just an example. I mean that stream in is filled…
Loom
  • 9,768
  • 22
  • 60
  • 112
1
vote
4 answers

How do I use std::ends to overwrite the string in an std::ostringstream?

I want to overwrite the string in an std::ostringstream but std::ends isn't working. Is this a problem with VS2012, or am I doing something wrong? Here is example code: std::ostringstream foo; foo << "1,2,3,4,5,6"; std::cout << foo.str(); //…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
1
vote
1 answer

Converting a char array to something that can be appended to a ostringstream

std::ostringstream parmStream; char parmName[1024]; THTTPUrl::Encode(parmName, pParm->Name().c_str(), 1024); //I want to add the value of the paramName to the parmStream worked b4 when parmName was a string but obv not now parmStream << "&" <<…
wmitchell
  • 5,665
  • 10
  • 37
  • 62
1
vote
1 answer

First SFML 2.1 GUI project crash

Today i started writing my firs SFML program, it is supposed to be a Snake game, and it was all going pretty well, until I started making the two dimension class array, which was supposed to hold the information of each tile. The some wierd stuff…
user2468893
  • 45
  • 1
  • 5
1
vote
4 answers

Reverse an ostringstream by line

ostringstream ss; ss << "(1,2)\n" << "(1,3)\n" << "(1,4)\n" ; cout << ss.str(); should print the following: (1,2) (1,3) (1,4) How could i reverse the output by line so that it prints: (1,4) (1,3) (1,2)
GoBlue_MathMan
  • 1,048
  • 2
  • 13
  • 20
1
vote
1 answer

Mac OS X port crashes in pthread_setspecific in glibstdc++ vsnprintf - how to troubleshoot?

I'm testing a Mac OS X port of my multithreaded server. It starts up, but it dies in vsnprintf soon after the first client request is taken by a worker thread. It seems that vsnprintf is trying to manipulate some thread local memory with…
Erik Olson
  • 1,154
  • 8
  • 18
1
vote
2 answers

C++ ostringstream strange behavior when chaining in cout is used

I am a C++ beginner ( came from Java ). I have the following code: //#include #include #include #include #include #include #include #include #include…
aureliangtx
  • 317
  • 6
  • 18
1
vote
1 answer

Setting std::io_base flags for custom stream class

I have a custom class called Stream class Stream public: Stream& operator<<(int i) { stream_ << i; return *this;} template Stream& operator<<(const CustomClass& c) { stream_ << c.toString() /*…
abumusamq
  • 780
  • 1
  • 10
  • 29
1
vote
1 answer

QString and stdstring combination doesnt work in std::stringstream - compile error

``` #include #include #include class Printer { public: inline std::ostream& operator<<(const std::string& str) { stream << str; return stream; } inline std::ostream& operator<<(int numb) { …
abumusamq
  • 780
  • 1
  • 10
  • 29