![]() ![]() ![]() The output will look something like: 0123456789abcdef0123456789abcdefĮvery two characters represents the 0-255 byte value of a byte in your data, using the base-16 (or "hex") numerical system. I don't know what "get the result in binary" means, but I suggest rendering the contents of your vector by printing its constituent bytes, one at a time, in their hex-pair representation: std::cout << std::hex << std::setfill('0') It doesn't have any effect at all on how your computer prints a string, seven lines later. Opening a file in binary mode means that your operating system won't transparently translate line endings between the CR/LF/CRLF formats. ![]() You can output byte values of your buffer this way: void dumpbytes(const vector& v)įor (int i = 0 i =' ' & c<='~') ? c : '.' īuffer with "Hello World!" data would be printed as follows: 48 65 6C 6C 6F 20 57 6F 72 6C 64 21 Hello World! Ifstream ifd("input.png", ios::binary | ios::ate) You need to resize your vector, not reserve it: int main() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |