how can I read exactly 128 bytes from an fstream into a string object? [duplicate]
问题 This question already has answers here : Reading directly from an std::istream into an std::string (6 answers) Closed 3 years ago . How do I read exactly 128 bytes from an fstream into a string object? I wrote some code to read the first 128 bytes of a file and print it and then the last 128 bytes of the file and print that. The last part works, since you can easily iterate to EOF, but how do I get exactly 128 bytes from the front? The code below doesn't work since you can't add 128 to an