Back to problems

Implement buffer readers for char/int/string with pointer advancement

Algorithm · Hudson River Trading · Medium

Problem You have a contiguous block of memory, represented as a char* or std::byte*, and a read pointer p that currently points somewhere inside that block. Your task is to implement three functions that each read the next value from the buffer and then advance p past that value, so that subsequent reads pick up where the last one left off. The three functions are: readChar: reads a single char. readInt: reads a single int. readString: reads a std::string. Requirements After…

Checking your access…