编辑代码

#include <stdio.h>

void toDigit(char * s){
    int n = 0;
    while(*s){
        n = n*10 + *s - '0';
        s++;
    }
    printf("%d",n);
}
int main () {
   char s[] = "123";
   toDigit(s);
	return 0;
}