|
|
1.1 root 1: .\" Copyright (c) 1990 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" This code is derived from software contributed to Berkeley by
5: .\" Chris Torek.
6: .\"
7: .\" Redistribution and use in source and binary forms are permitted
8: .\" provided that: (1) source distributions retain this entire copyright
9: .\" notice and comment, and (2) distributions including binaries display
10: .\" the following acknowledgement: ``This product includes software
11: .\" developed by the University of California, Berkeley and its contributors''
12: .\" in the documentation or other materials provided with the distribution
13: .\" and in all advertising materials mentioning features or use of this
14: .\" software. Neither the name of the University nor the names of its
15: .\" contributors may be used to endorse or promote products derived
16: .\" from this software without specific prior written permission.
17: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18: .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20: .\"
21: .\" @(#)strtoul.3 5.1 (Berkeley) 5/15/90
22: .\"
23: .TH STRTOUL 3 "May 15, 1990"
24: .UC 7
25: .SH NAME
26: strtoul \- convert a string to an unsigned long integer
27: .SH SYNOPSIS
28: .B #include <stdlib.h>
29: .br
30: .B #include <limits.h>
31: .PP
32: .B "unsigned long strtoul(char *nptr, char **endptr, int base);
33: .SH DESCRIPTION
34: .B Strtoul
35: converts the string in
36: .I nptr
37: to an
38: .B "unsigned long"
39: value according to the given
40: .IR base ,
41: which must be between 2 and 36 inclusive,
42: or be the special value 0.
43: .PP
44: The string may begin with an arbitrary amount of white space
45: (as determined by
46: .BR isspace ;
47: see
48: .IR ctype (3)),
49: followed by a single optional `+' or `-' sign.
50: If
51: .I base
52: is zero or 16,
53: the string may then include a `0x' prefix,
54: and the number will be read in base 16; otherwise, a zero
55: .I base
56: is taken as 10 (decimal) unless the next character is `0',
57: in which case it is taken as 8 (octal).
58: .PP
59: The remainder of the string is converted to an
60: .B "unsigned long"
61: value in the obvious manner,
62: stopping at the end of the string
63: or at the first character that does not produce a valid digit
64: in the given base.
65: (In bases above 10, the letter `A' in either upper or lower case
66: represents 10, `B' represents 11, and so forth, with `Z' representing 35.)
67: .PP
68: If
69: .I endptr
70: is non nil,
71: .B strtoul
72: stores the address of the first invalid character in
73: .IR *endptr .
74: If there were no digits at all, however,
75: .B strtoul
76: stores the original value of
77: .I nptr
78: in
79: .IR *endptr .
80: (Thus, if
81: .I *nptr
82: is not '\e0' but
83: .IR **endptr
84: is '\e0' on return, the entire string was valid.)
85: .SH RETURN VALUE
86: .B Strtoul
87: returns either the result of the conversion
88: or, if there was a leading minus sign,
89: the negation of the result of the conversion,
90: unless the original (non-negated) value would overflow;
91: in the latter case,
92: .B strtoul
93: returns
94: .B ULONG_MAX
95: and sets
96: .B errno
97: to
98: .BR ERANGE .
99: .SH ERRORS
100: .TP
101: [ERANGE]
102: The given string was out of range; the value converted has been clamped.
103: .SH SEE ALSO
104: strtol(3)
105: .SH STANDARDS
106: .B Strtoul
107: conforms to ANSI X3.159-1989 (``ANSI C'').
108: .SH BUGS
109: Ignores the current locale.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.