Created
December 3, 2024 20:55
-
-
Save brandonprry/b2cecc09973533d8ec24336c5059ced4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t* readAllStdin(size_t& length) { | |
std::vector<uint8_t> buffer; | |
char temp; | |
// Read all input data from stdin | |
while (std::cin.get(temp)) { | |
buffer.push_back(static_cast<uint8_t>(temp)); | |
} | |
// Allocate memory for the buffer and copy the data | |
length = buffer.size(); | |
uint8_t* data = new uint8_t[length]; | |
std::copy(buffer.begin(), buffer.end(), data); | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment