stdlib.c

Go to the documentation of this file.
00001 /* stdlib.c */
00002 
00003 #include <sys/types.h>
00004 #include <routix/system.h>
00005 #include <string.h>
00006 
00007 /* Ascii to Integer
00008  * "1943" => 1 * 10^3 + 9 * 10^2 + 4 * 10^1 + 3 * 10^0
00009  */
00010 int atoi(const char *str)
00011 {
00012  int numero = 0;
00013  int multiplicador = 1;
00014 
00015  size_t largo;
00016 
00017  for (largo = strlen(str) - 1 , multiplicador=1; largo > -1 ; largo--, multiplicador *= 10 )
00018   numero += ( *(str+largo) - '0' ) * multiplicador;
00019 
00020  return numero;
00021 }

Generated on Sun May 30 18:38:35 2004 for Routix OS by doxygen 1.3.6