int myatoi(const char *string);
int main(int argc, char* argv[])
{
printf("\n%d\n", myatoi("1992"));
getch();
return 0;
}
int myatoi(const char *string)
{
int i;
i=0;
while(*string)
{
i=i*10;
i=i + (*string - '0');
string++;
// Dont increment i!
}
return(i);
}
int main(int argc, char* argv[])
{
printf("\n%d\n", myatoi("1992"));
getch();
return 0;
}
int myatoi(const char *string)
{
int i;
i=0;
while(*string)
{
i=i*10;
i=i + (*string - '0');
string++;
// Dont increment i!
}
return(i);
}
No comments:
Post a Comment