I have this code that reads from stdin into a char*. Is it possible to do this directly into a std::string?
int size = std::atoi(m_content_size);
char* buffer;
buffer = (char*)malloc(size);
fread(buffer, 1, size, stdin);
...
free(buffer);
I suppose I could do std::string sBuffer(buffer), but I’m hoping there is a better alternative.
Thank you.
You should probably read into a vector of chars or so, just so as to not give the impression that you have “text” if you really have arbitrary binary data: