A
akitoto
Hi there,
I am using the std::stringstream to create a byte array in memory. But
it is not working properly. Can anyone help me?
Code:
#include <vector>
#include <sstream>
#include <iostream.h>
int main(int argc, char* argv[])
{
std::vector<double> vector (2, 12.3456);
std::stringstream stream
(std::stringstream:ut|std::stringstream::binary);
unsigned int sz = vector.size();
stream << sz;
for (unsigned int i = 0; i < sz; i++)
{
stream << vector;
}
//results
std::string buffer = stream.str();
cout << buffer.c_str() << endl;
return 0;
}
output:
212.345612.3456
Why is the output not some byte-sequence, but formatted text?
I am using the std::stringstream to create a byte array in memory. But
it is not working properly. Can anyone help me?
Code:
#include <vector>
#include <sstream>
#include <iostream.h>
int main(int argc, char* argv[])
{
std::vector<double> vector (2, 12.3456);
std::stringstream stream
(std::stringstream:ut|std::stringstream::binary);
unsigned int sz = vector.size();
stream << sz;
for (unsigned int i = 0; i < sz; i++)
{
stream << vector;
}
//results
std::string buffer = stream.str();
cout << buffer.c_str() << endl;
return 0;
}
output:
212.345612.3456
Why is the output not some byte-sequence, but formatted text?