blob: 74e113d9c033b8ad5c3cbeb1b5957373dc363681 [file] [log] [blame]
<html lang="en">
<head>
<title>strtoull - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Stdlib.html#Stdlib" title="Stdlib">
<link rel="prev" href="strtoul.html#strtoul" title="strtoul">
<link rel="next" href="wcsrtombs.html#wcsrtombs" title="wcsrtombs">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="strtoull"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="wcsrtombs.html#wcsrtombs">wcsrtombs</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="strtoul.html#strtoul">strtoul</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a>
<hr>
</div>
<h3 class="section">2.38 <code>strtoull</code>&mdash;string to unsigned long long</h3>
<p><a name="index-strtoull-88"></a><a name="index-g_t_005fstrtoull_005fr-89"></a><strong>Synopsis</strong>
<pre class="example"> #include &lt;stdlib.h&gt;
unsigned long long strtoull(const char *<var>s</var>, char **<var>ptr</var>,
int <var>base</var>);
unsigned long long _strtoull_r(void *<var>reent</var>, const char *<var>s</var>,
char **<var>ptr</var>, int <var>base</var>);
</pre>
<p><strong>Description</strong><br>
The function <code>strtoull</code> converts the string <code>*</code><var>s</var> to
an <code>unsigned long long</code>. First, it breaks down the string into three parts:
leading whitespace, which is ignored; a subject string consisting
of the digits meaningful in the radix specified by <var>base</var>
(for example, <code>0</code> through <code>7</code> if the value of <var>base</var> is 8);
and a trailing portion consisting of one or more unparseable characters,
which always includes the terminating null character. Then, it attempts
to convert the subject string into an unsigned long long integer, and returns the
result.
<p>If the value of <var>base</var> is zero, the subject string is expected to look
like a normal C integer constant (save that no optional sign is permitted):
a possible <code>0x</code> indicating hexadecimal radix, and a number.
If <var>base</var> is between 2 and 36, the expected form of the subject is a
sequence of digits (which may include letters, depending on the
base) representing an integer in the radix specified by <var>base</var>.
The letters <code>a</code>&ndash;<code>z</code> (or <code>A</code>&ndash;<code>Z</code>) are used as digits valued from
10 to 35. If <var>base</var> is 16, a leading <code>0x</code> is permitted.
<p>The subject sequence is the longest initial sequence of the input
string that has the expected form, starting with the first
non-whitespace character. If the string is empty or consists entirely
of whitespace, or if the first non-whitespace character is not a
permissible digit, the subject string is empty.
<p>If the subject string is acceptable, and the value of <var>base</var> is zero,
<code>strtoull</code> attempts to determine the radix from the input string. A
string with a leading <code>0x</code> is treated as a hexadecimal value; a string with
a leading <code>0</code> and no <code>x</code> is treated as octal; all other strings are
treated as decimal. If <var>base</var> is between 2 and 36, it is used as the
conversion radix, as described above. Finally, a pointer to the first
character past the converted subject string is stored in <var>ptr</var>, if
<var>ptr</var> is not <code>NULL</code>.
<p>If the subject string is empty (that is, if <code>*</code><var>s</var> does not start
with a substring in acceptable form), no conversion
is performed and the value of <var>s</var> is stored in <var>ptr</var> (if <var>ptr</var> is
not <code>NULL</code>).
<p>The alternate function <code>_strtoull_r</code> is a reentrant version. The
extra argument <var>reent</var> is a pointer to a reentrancy structure.
<p><br>
<strong>Returns</strong><br>
<code>strtoull</code> returns the converted value, if any. If no conversion was
made, <code>0</code> is returned.
<p><code>strtoull</code> returns <code>ULONG_LONG_MAX</code> if the magnitude of the converted
value is too large, and sets <code>errno</code> to <code>ERANGE</code>.
<p><br>
<strong>Portability</strong><br>
<code>strtoull</code> is ANSI.
<p><code>strtoull</code> requires no supporting OS subroutines.
<p><br>
</body></html>