• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/libc/
1<html lang="en">
2<head>
3<title>strtoul - Untitled</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Untitled">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Stdlib.html#Stdlib" title="Stdlib">
9<link rel="prev" href="strtoll.html#strtoll" title="strtoll">
10<link rel="next" href="strtoull.html#strtoull" title="strtoull">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<meta http-equiv="Content-Style-Type" content="text/css">
13<style type="text/css"><!--
14  pre.display { font-family:inherit }
15  pre.format  { font-family:inherit }
16  pre.smalldisplay { font-family:inherit; font-size:smaller }
17  pre.smallformat  { font-family:inherit; font-size:smaller }
18  pre.smallexample { font-size:smaller }
19  pre.smalllisp    { font-size:smaller }
20  span.sc    { font-variant:small-caps }
21  span.roman { font-family:serif; font-weight:normal; } 
22  span.sansserif { font-family:sans-serif; font-weight:normal; } 
23--></style>
24<link rel="stylesheet" type="text/css" href="../cs.css">
25</head>
26<body>
27<div class="node">
28<a name="strtoul"></a>
29<p>
30Next:&nbsp;<a rel="next" accesskey="n" href="strtoull.html#strtoull">strtoull</a>,
31Previous:&nbsp;<a rel="previous" accesskey="p" href="strtoll.html#strtoll">strtoll</a>,
32Up:&nbsp;<a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a>
33<hr>
34</div>
35
36<h3 class="section">2.37 <code>strtoul</code>&mdash;string to unsigned long</h3>
37
38<p><a name="index-strtoul-86"></a><a name="index-g_t_005fstrtoul_005fr-87"></a><strong>Synopsis</strong>
39<pre class="example">     #include &lt;stdlib.h&gt;
40     unsigned long strtoul(const char *<var>s</var>, char **<var>ptr</var>,
41         int <var>base</var>);
42     
43     unsigned long _strtoul_r(void *<var>reent</var>, const char *<var>s</var>,
44         char **<var>ptr</var>, int <var>base</var>);
45     
46</pre>
47   <p><strong>Description</strong><br>
48The function <code>strtoul</code> converts the string <code>*</code><var>s</var> to
49an <code>unsigned long</code>. First, it breaks down the string into three parts:
50leading whitespace, which is ignored; a subject string consisting
51of the digits meaningful in the radix specified by <var>base</var>
52(for example, <code>0</code> through <code>7</code> if the value of <var>base</var> is 8);
53and a trailing portion consisting of one or more unparseable characters,
54which always includes the terminating null character. Then, it attempts
55to convert the subject string into an unsigned long integer, and returns the
56result.
57
58   <p>If the value of <var>base</var> is zero, the subject string is expected to look
59like a normal C integer constant (save that no optional sign is permitted):
60a possible <code>0x</code> indicating hexadecimal radix, and a number. 
61If <var>base</var> is between 2 and 36, the expected form of the subject is a
62sequence of digits (which may include letters, depending on the
63base) representing an integer in the radix specified by <var>base</var>. 
64The letters <code>a</code>&ndash;<code>z</code> (or <code>A</code>&ndash;<code>Z</code>) are used as digits valued from
6510 to 35. If <var>base</var> is 16, a leading <code>0x</code> is permitted.
66
67   <p>The subject sequence is the longest initial sequence of the input
68string that has the expected form, starting with the first
69non-whitespace character.  If the string is empty or consists entirely
70of whitespace, or if the first non-whitespace character is not a
71permissible digit, the subject string is empty.
72
73   <p>If the subject string is acceptable, and the value of <var>base</var> is zero,
74<code>strtoul</code> attempts to determine the radix from the input string. A
75string with a leading <code>0x</code> is treated as a hexadecimal value; a string with
76a leading <code>0</code> and no <code>x</code> is treated as octal; all other strings are
77treated as decimal. If <var>base</var> is between 2 and 36, it is used as the
78conversion radix, as described above. Finally, a pointer to the first
79character past the converted subject string is stored in <var>ptr</var>, if
80<var>ptr</var> is not <code>NULL</code>.
81
82   <p>If the subject string is empty (that is, if <code>*</code><var>s</var> does not start
83with a substring in acceptable form), no conversion
84is performed and the value of <var>s</var> is stored in <var>ptr</var> (if <var>ptr</var> is
85not <code>NULL</code>).
86
87   <p>The alternate function <code>_strtoul_r</code> is a reentrant version.  The
88extra argument <var>reent</var> is a pointer to a reentrancy structure.
89
90   <p><br>
91<strong>Returns</strong><br>
92<code>strtoul</code> returns the converted value, if any. If no conversion was
93made, <code>0</code> is returned.
94
95   <p><code>strtoul</code> returns <code>ULONG_MAX</code> if the magnitude of the converted
96value is too large, and sets <code>errno</code> to <code>ERANGE</code>.
97
98   <p><br>
99<strong>Portability</strong><br>
100<code>strtoul</code> is ANSI.
101
102   <p><code>strtoul</code> requires no supporting OS subroutines.
103
104   <p><br>
105
106   </body></html>
107
108