Skip to main content

Practice ยท 4 of 5

Literals are Lvalues

CHALLENGE
Difficulty: advanced+25 XP

Implement size_t literal_addr_delta(void): take the address of the string literal "ca" twice (two separate &"ca"[0] expressions), return the byte distance between them as a size_t (0 if equal). Then implement int literal_is_lvalue(void) returning 1 unconditionally โ€” because taking that address compiled at all, proving literals are lvalues (modifying them would be UB, not a compile error).

Back to lesson: Practice: Sequencing and Lifetime Drills