Is it possible to put a const char* into a string stream?
I think it's possible with the write() function in stringstream but I'm having trouble figuring out how to get the streamsize if i only know of the const char *.
Assuming size is my const char * variable:
stringstream s;
s.write(temp,size);
How do I get size? Thanks.
I tested it, and it works correctly...
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
stringstream s;
const char* token = "HELLO";
s << token;
cout << s.str() << endl;
return 0;
}
[facu@arch ~]$ g++ p.cpp
[facu@arch ~]$ ./a.out
HELLO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With