Output stream class to operate on strings.
Questions tagged [ostringstream]
150 questions
0
votes
1 answer
Access Violation - dereferenced ostringstream
I have a ostringstream object that I am trying to insert some characters into, but the ostringstream object is in a shared_ptr called pOut. When I try to dereference pOut, I always get an Access Violation error.
This is a simplified version of what…

bmb
- 361
- 2
- 13
0
votes
1 answer
convert boost beast http request to a string and write to ostringstream
I am trying to make a http call using boost beast and want to write it before writing to socket; i tried to use ostringstream to get the value of request to get it in printed log and getting the below error message:
string verb = "POST";
using…

Krishna Moorthy
- 113
- 11
0
votes
2 answers
Why does a member of ostringstream type in class cause "call to implicity deleted copy-constructor" error?
I have isolated a problem with "call to implicitly deleted copy-constructor" compilation errors to the use of an ostringstream type in declaring members of a class. In the example below, a STL list of objects of the example's Reading class is…

Spangas
- 15
- 2
0
votes
0 answers
How can I clear ostringstream without clearing a iomanip flags?
I have a issue in display string stream content. I want to make string stream containing timer time with fixed 2 numbers before and after point.
To not recreate over and over i decided to make it in constructor of class that have it. I make…

BoomboxPL
- 1
- 1
0
votes
1 answer
Redirecting from standard output to custom stream during program execution
I have a function which redirects messages from the standard output to a log file. The problem is, the messages are only written into the log file after the end of the program. Is it possible to write to the log file when the program is running? So,…

Loki
- 35
- 6
0
votes
0 answers
Does log4cpp takes care of heap fragmentations issue?
I develop on windows 64bit with VS2015.
I used a custom logger but it suffered from heap fragmentations.
I found log4cpp library. According to the source code it uses std::ostringstream internally.
My questions:
I think my main question is can I…

theateist
- 13,879
- 17
- 69
- 109
0
votes
3 answers
How to log a hex string in c++ with ostringstream?
I'm trying to log hex values to an ostringstream, but it's not working. I'm trying:
unsigned char buf[4];
buf[0] = 0;
buf[1] = 1;
buf[2] = 0xab;
buf[3] = 0xcd;
std::ostringstream e1;
e1 << "0x" << std::setfill('0') << std::setw(3) << std::hex <<…

Thundercleez
- 327
- 1
- 4
- 18
0
votes
0 answers
Misinterpretation of operator precedence when using ostream and ostringstream
The following code has different compile results. From the error message I'm receiving it seems there's a confusion about operators precedence () and <<. I can easily overcome this issue by using a function. However I would like to understand and to…

Jacinto Resende
- 343
- 2
- 13
0
votes
1 answer
binary '<<' : no operator found which takes a left-hand operand of type 'std::basic_ostream>'
There is a function which gets std::ostream& as an arguments and performs some operations:
inline std::ostream& my_function(std::ostream& os, int n) {
// some operations
return os;
}
And there is another function that calls…
user3336051
0
votes
1 answer
ostringstream is empty after inserting output to it
I have a strange issue where ostringstream is empty even though I insert an output to it.
Here is my code:
//logger.h
#include
#include
#include
using std::string;
class BasicLogger {
public:
BasicLogger(const…

Morad
- 2,761
- 21
- 29
0
votes
1 answer
Weird memory issue with ostringstream / ostream using valgrind
I get this memory issue with valgrind that I cannot make any sense out of. Just adding a line which access the ostream seems to get rid of the memory issue, but that is obviously not the way I want to go. Any ideas what could be wrong? Input to the…

Joachim
- 81
- 1
- 3
- 9
0
votes
0 answers
stringstream::write() evokes segmentation fault in C++
using namespace std;
void *gen_random(void *data, const int len) {
for (int i = 0; i < len; ++i) {
*((unsigned char *)data + i) = rand() % UCHAR_MAX;
}
return data;
}
void idx_sort_swap(unsigned long long &small, unsigned long…

user3498780
- 89
- 8
0
votes
2 answers
Validating a date format in c++
I'm trying to validate a date format on on a line such as this one (01 10 2017) by creating a stream.
if(i%5==4){ //DATE
std::string date;
int day;
int month;
int year;
…
user8729399
0
votes
1 answer
Does ostringstream object need to be cleared?
I am using an ostringstream object in an application that runs for a long time to print debug information to standard out. I toggle whether the application actually prints and clears the ostringstream object based on a command line arg (e.g.,…

BigBrownBear00
- 1,378
- 2
- 14
- 24
0
votes
0 answers
How to access data from `std::ostringstream` without copying it
I'm using std::ostringstream to serialize data to send it through sockets later. Now I'm using std::ostringstream::str() function to get access to the data, but I would like to avoid copying the data.
Is this possible to get access to the…

Mircea Ispas
- 20,260
- 32
- 123
- 211