DIGIT-ARC read-only archive · snapshot: July 23, 2026

C Programming

3 posts · originally from https://geek.digit.in/community/threads/c-programming.43196/

Ishan
Ishan Original post #1
Dec 8, 2006 at 6:54 PM
HOW TO CREATE MY OWN
atoi() function.
pls give me the logic.
its urgent.
kalpik
kalpik #2
Dec 8, 2006 at 7:44 PM
One tip: The ASCII value of (char) '0' is (int) 48. So just make a loop and extract these values! Also remember that you have to do the units, tens, hundred math also!

int num=0;
for(i=0;i<strlen(string);i++)
{
num=num+(((int)string-48)*pow(10,i));
}

I think the above code should work!
tuxfan
tuxfan #3
Dec 8, 2006 at 7:44 PM
HINT: switch case, while()/for() loop, if..else

Or are you expecting code?