C++ equivalent of Java ByteBuffer?
问题 I'm looking for a C++ "equivalent" of Java ByteBuffer. I'm probably missing the obvious or just need an isolated usage example to clarify. I've looked through the iostream family & it looks like it may provide a basis. Specifically, I want to be able to: build a buffer from a byte array/point and get primitives from the buffer, e.g. getByte, getInt build a buffer using primitives e.g. putByte, putInt and then get the byte array/pointer. 回答1: You have stringbuf , filebuf or you could use