Hi!
The following program gives the integer value of char string as output.Suppose if we give "1998",it will give integer 1998.In

i=i<<3+i<<1+(*string-'0')

I understood that it will multiply i by 10,but in *string-'0' I don't know what is going there..?.Here what refers string is it index in 1998 or whole 1998.
How this program works..?.What we are incrementing at string++ is it index.Please explain me I am a newbie...!
Any help would be highly appreciated.Thanxx

#include<stdio.h>

int myatoi(char *string);

int main(int argc, char* argv[])
{
printf("n%dn\n", myatoi("1998"));

return(0);
}

int myatoi(char *string)
{
int i;
i=0;
while(*string)
{
i=(i<<3) + (i<<1) + (*string-'0');
printf("%d\n",i);
string++;

// Dont increment i!

}
return(i);
}