Code Room
Code reviewMedium
Question
Review this C++ code that caches a C string for a logging library.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
struct LogLine { const char* msg; }; LogLine make_line(int code) { std::string s = "error " + std::to_string(code); return LogLine{ s.c_str() }; // hand the C string to the sink} auto line = make_line(500);logger.emit(line.msg);Run or narrate your approach, then ask the coach.