Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
Main Page
Related Pages
+
Classes
Class List
Class Index
+
Class Members
+
All
_
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
w
x
+
Variables
_
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
w
x
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
p
q
r
s
t
u
v
w
+
Variables
_
b
c
d
e
f
h
i
l
n
p
t
v
w
+
Typedefs
_
a
b
c
d
f
i
j
n
s
t
u
v
w
Enumerator
+
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerator
Macros
Pages
atoi.c
Go to the documentation of this file.
1
#include <
ctype.h
>
2
#include <
stdbool.h
>
3
#include <
stdlib.h
>
4
5
int
atoi
(
const
char
* str)
6
{
7
bool
neg =
false
;
8
int
val = 0;
9
10
switch
(*str)
11
{
12
case
'-'
:
13
neg =
true
;
14
// intentional fallthrough to advance str
15
case
'+'
:
16
str++;
17
}
18
19
while
(
isdigit
(*str))
20
{
21
val = (10 * val) + (*str++ -
'0'
);
22
}
23
24
return
(neg ? -val : val);
25
}
ctype.h
atoi
int atoi(const char *str)
Interprets an integer value in a byte string pointed to by str.
Definition:
atoi.c:5
stdlib.h
stdbool.h
isdigit
int isdigit(int ch)
Checks if the given character is a numeric character.
Definition:
isdigit.c:5
src
stdlib
atoi.c
Generated by
1.8.15