1 #include<stdio.h> 2 int fun(char *p,char *p1) 3 { 4 char *ch,*ch1; 5 int sum=0,temp=0; 6 ch=p,ch1=p1; 7 while(*ch) //抓取每个位置上的字符转换成数字 8 { 9 temp=temp*10+(*ch-'0'); //每次累加一个数字后乘十移位 10 ch++; 11 } 12 sum+=temp; //将第一个字符串的数先累加到sum 13 temp=0; //归零进行下一次运算 14 while(*ch1) 15 { 16 temp=temp*10+(*ch1-'0'); 17 ch1++; 18 } 19 return (sum+=temp); 20 } 21 int main() 22 { 23 char a[100],b[100]; 24 gets(a); 25 gets(b); 26 printf("%d",fun(a,b)); 27 return 0; 28 }