diff options
author | David <dbphillipsnz@gmail.com> | 2013-08-14 15:56:17 +1200 |
---|---|---|
committer | David <dbphillipsnz@gmail.com> | 2014-03-27 20:32:47 +1300 |
commit | 9d9de30b314f763069ed18fe8da8b6187d6faf38 (patch) | |
tree | 8f5c182d423da7256e491e6d332f8e162ec83fe6 /string/common.c | |
parent | e8b4c2e0631426ac7ee596884d35432d02afdb57 (diff) | |
download | toast-9d9de30b314f763069ed18fe8da8b6187d6faf38.tar.xz |
Bugfixes
Diffstat (limited to 'string/common.c')
-rw-r--r-- | string/common.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/string/common.c b/string/common.c index b303cb0..d61bdff 100644 --- a/string/common.c +++ b/string/common.c @@ -45,14 +45,17 @@ void itoa(uint32_t num,char *buffer) } -void atoi(char *string) +uint32_t atoi(char *string) { uint32_t i; - uint32_t multiplier; + uint32_t multiplier = 1; + uint32_t total = 0; for (i = 0; i < strlen(string); i++) { - + total += (string[strlen(string)-1-i] - 48) * multiplier; + multiplier*=10; } + return total; } #endif |