1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>kstrtoint</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Linux Kernel API"><link rel="up" href="libc.html#idp1122555668" title="String Conversions"><link rel="prev" href="API-kstrtouint.html" title="kstrtouint"><link rel="next" href="ch02s02.html" title="String Manipulation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">kstrtoint</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-kstrtouint.html">Prev</a>&#160;</td><th width="60%" align="center">String Conversions</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch02s02.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-kstrtoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>kstrtoint &#8212; 
2     convert a string to an int
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">kstrtoint </b>(</code></td><td>const char * <var class="pdparam">s</var>, </td></tr><tr><td>&#160;</td><td>unsigned int <var class="pdparam">base</var>, </td></tr><tr><td>&#160;</td><td>int * <var class="pdparam">res</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1122790604"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>s</code></em></span></dt><dd><p>
4     The start of the string. The string must be null-terminated, and may also
5     include a single newline before its terminating null. The first character
6     may also be a plus sign or a minus sign.
7    </p></dd><dt><span class="term"><em class="parameter"><code>base</code></em></span></dt><dd><p>
8     The number base to use. The maximum supported base is 16. If base is
9     given as 0, then the base of the string is automatically detected with the
10     conventional semantics - If it begins with 0x the number will be parsed as a
11     hexadecimal (case insensitive), if it otherwise begins with 0, it will be
12     parsed as an octal number. Otherwise it will be parsed as a decimal.
13    </p></dd><dt><span class="term"><em class="parameter"><code>res</code></em></span></dt><dd><p>
14     Where to write the result of the conversion on success.
15    </p></dd></dl></div></div><div class="refsect1"><a name="idp1122794724"></a><h2>Description</h2><p>
16   Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
17   Used as a replacement for the obsolete simple_strtoull. Return code must
18   be checked.
19</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-kstrtouint.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="libc.html#idp1122555668">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch02s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">kstrtouint</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;String Manipulation</td></tr></table></div></body></html>
20