networking · beginner · ~15 min

Milliseconds to timeval microseconds

Compute the tv_usec remainder.

Challenge

Implement long ms_to_usec(long ms) returning the leftover microseconds (the sub-second part of ms, in microseconds) for the tv_usec field.

Starter code

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

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