Soft'N'Design Software
/
projects
/
calc.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
fix percent printing
[calc.git]
/
atoi.c
1
#include
"atoi.h"
2
3
int
atoi
(
char
*
str
)
4
{
5
int
i
=
0
;
6
int
s
=
1
;
7
8
if
(*
str
==
'-'
) {
9
s
=
0
;
10
str
++;
11
}
12
13
while
(*
str
!=
0
) {
14
if
((*
str
<
'0'
) || (*
str
>
'9'
)) {
15
return
0
;
16
}
17
i
=
i
*
10
+ (
int
)(*(
str
++) -
'0'
);
18
}
19
20
return
(
s
) ?
i
: -
i
;
21
}
22
23
/* vim: set ts=4 sw=4 et: */