Code Room
Code reviewMediumcr-g371
Subject Dangling pointerLevel Mid–Senior~18 minCommon in Algorithms & data structures interviewsIndustries Software development, Telecom

Question

Review this C helper that formats an IPv4 address into a string for logging.

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.

Talk through your review
Code to reviewc
const char *ip_to_str(uint32_t ip) {    char buf[16];    snprintf(buf, sizeof buf, "%u.%u.%u.%u",             (ip >> 24) & 0xff, (ip >> 16) & 0xff,             (ip >> 8) & 0xff, ip & 0xff);    return buf;   // hand the formatted string back} // caller:log_msg("src=%s", ip_to_str(pkt->src));
Run or narrate your approach, then ask the coach.