高手帮忙看下代码有什么问题!
#include<stdio.h>int sum(long num) /*求一个十进制6位正整数各位数字之和*/
{
long a = 0, b = 0, len;
int sum = 0;
for(len = 100000; len > 0; len = len / 10) {
a = num / len;
b = num % len;
sum = sum + a;
num = b;
}
return sum;
}
int main()
{
int a;
long num;
scanf("%l", &num);
printf("%d", sum(num));
}
问题是出在for语句块里面,但我不知道是什么问题,望高手能给我解答.