String to Integer conversion function | C Programming and Computer Geeks

Search MY Blog

Thursday, 19 December 2013

String to Integer conversion function


int strtoint(char str[])
{
  int i=0,num=0;
    
  while (str[i]!='\0')
  {
     num=num*10+str[i]-'0';
     i++;
  }

  printf("Entered String = \"%s\" , After String to Int = %d",str, num);

  return num;
}

Output:

String to Integer Conversion
string to integer

 
Click here for more C Faq

Search This Blog