Skip to main content

Practice ยท 1 of 4

One Object, Many Promises

Implement a shared-external pattern in one TU: ``c int attempts = 0; /* the definition (external linkage) */ void record_attempt(void); /* increments attempts */ int peek_attempts(void); /* returns attempts */ ` record_attempt must be safe to call any number of times. Then implement int reset_attempts(void)` which zeroes attempts and returns how many were recorded since the last reset.

Difficulty: intermediate

Back to lesson: Practice: Duration & Linkage Gym