You got the wrong result because there are a lot of errors in you code.
Try:
#include <stdio.h>
int ascii_to_int(const char *s);
void main()
{
printf("%d",ascii_to_int( "0101"));
getchar();
}
int ascii_to_int(const char *s)
{
int value=0;
while(*s>='0' && *s<='9')
{
value = value * 10 + (*s-'0');
s++;
}
return value;
}