this is c program to convert number string into integer. I think that the if statement is not getting executed. I want to compare string[a] with the ascii value representented by number in integer i.
//to convert number string to integer
#include<stdio.h>
#include<string.h>
void main()
{
int a=0, copy[10]={0},len,i;
char string[10];
clrscr();
puts("enter a number string");
gets(string);
len=strlen(string);
while(a<len)
{
for(i=48;i<=57;i++)
{
if(string[a]==i)
{
copy[a]=i-48;
break;
}
a++;
}
}
for(i=0;i<len;i++)
printf("%d",copy[i]);
getch();
}