diff options
Diffstat (limited to 'man7/system_data_types.7')
-rw-r--r-- | man7/system_data_types.7 | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/man7/system_data_types.7 b/man7/system_data_types.7 index 3ab3e1d84..6bbf71004 100644 --- a/man7/system_data_types.7 +++ b/man7/system_data_types.7 @@ -276,42 +276,42 @@ are used as explained in the notes section above. #include <stdio.h> #include <stdlib.h> #include <sys/types.h> - +\& int main (void) { static const char *const str = "500000 us in half a second"; suseconds_t us; intmax_t tmp; - +\& /* Scan the number from the string into the temporary variable. */ - +\& sscanf(str, "%jd", &tmp); - +\& /* Check that the value is within the valid range of suseconds_t. */ - +\& if (tmp < \-1 || tmp > 1000000) { fprintf(stderr, "Scanned value outside valid range!\en"); exit(EXIT_FAILURE); } - +\& /* Copy the value to the suseconds_t variable \[aq]us\[aq]. */ - +\& us = tmp; - +\& /* Even though suseconds_t can hold the value \-1, this isn\[aq]t a sensible number of microseconds. */ - +\& if (us < 0) { fprintf(stderr, "Scanned value shouldn\[aq]t be negative!\en"); exit(EXIT_FAILURE); } - +\& /* Print the value. */ - +\& printf("There are %jd microseconds in half a second.\en", (intmax_t) us); - +\& exit(EXIT_SUCCESS); } .EE |