|
|
1.1 ! root 1: .\"#ident "@(#)ccsman:g3c/strtol 1.2" ! 2: '\"macro stdmacro ! 3: .nr X ! 4: .if \nX=0 .ds x} STRTOL 3L "630 MTG" "\&" ! 5: .TH \*(x} ! 6: .SH NAME ! 7: strtol, atol, atoi \- convert string to integer ! 8: .SH SYNOPSIS ! 9: .nf ! 10: .B long strtol (str, ptr, base) ! 11: .B char \(**str, \(**\(**ptr; ! 12: .B int base; ! 13: .PP ! 14: .B long atol (str) ! 15: .B char \(**str; ! 16: .PP ! 17: .B int atoi (str) ! 18: .B char \(**str; ! 19: .SH DESCRIPTION ! 20: .I strtol\^ ! 21: returns (as a long integer) the value represented by the character string ! 22: pointed to by ! 23: .IR str . ! 24: The string is scanned up to the first ! 25: character inconsistent with the base. ! 26: Leading ``white-space'' characters ! 27: [as defined by ! 28: .I isspace\^ ! 29: in ! 30: .IR ctype (3L)] ! 31: are ignored. ! 32: .PP ! 33: If the value of ! 34: .I ptr\^ ! 35: is not (char \(**\(**)\s-1NULL\s+1, ! 36: a pointer to the character terminating the scan is returned in ! 37: the location pointed to by ! 38: .IR ptr . ! 39: If no integer can be formed, ! 40: that location ! 41: is set to ! 42: .IR str , ! 43: and zero is returned. ! 44: .PP ! 45: If ! 46: .I base\^ ! 47: is positive (and not greater than 36), it is used as ! 48: the base for conversion. ! 49: After an optional leading sign, leading zeros are ignored, ! 50: and ``0x'' or ``0X'' is ignored if ! 51: .I base\^ ! 52: is 16. ! 53: .PP ! 54: If ! 55: .I base\^ ! 56: is zero, the string itself determines the base thusly: After an ! 57: optional leading sign, a leading zero indicates octal conversion, ! 58: and a leading ``0x'' or ``0X'' indicates a hexadecimal conversion. Otherwise, ! 59: decimal conversion is used. ! 60: .PP ! 61: Truncation from long to int can, of course, take place upon ! 62: assignment or by an explicit cast. ! 63: .PP ! 64: .I Atol(str)\^ ! 65: is equivalent to ! 66: .IR "strtol(str, (char \(**\(**)\s-1NULL\s+1, 10)" . ! 67: .PP ! 68: .I Atoi(str)\^ ! 69: is equivalent to ! 70: .IR "(int) strtol(str, (char \(**\(**)\s-1NULL\s+1, 10)" . ! 71: .SH SEE ALSO ! 72: atof(3L), ctype(3L). ! 73: .SH WARNING ! 74: Overflow conditions are ignored. ! 75: .Ee
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.