View Full Version : C Programming
Ishan
08-12-2006, 06:54 PM
HOW TO CREATE MY OWN
atoi() function.
pls give me the logic.
its urgent.
kalpik
08-12-2006, 07: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[i]-48)*pow(10,i));
}
I think the above code should work!
tuxfan
08-12-2006, 07:44 PM
HINT: switch case, while()/for() loop, if..else
Or are you expecting code?
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.