networking · beginner · ~15 min

Milliseconds to timeval seconds

Split milliseconds into the seconds field.

Challenge

SO_RCVTIMEO uses a struct timeval. Implement long ms_to_sec(long ms) returning the whole-seconds part of ms.

Starter code

long ms_to_sec(long ms) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.