我一直在尝试使用该程序查找给定数字的长度,但是每次运行它都会收到以下错误:
check_length.c:16:26:运行时错误:被零除
#include <cs50.h>
#include <stdio.h>
void check_length(long);
int main(void)
{
long c = get_long("Enter Number: ");
check_length(c);
}
void check_length(long w)
{
for(int i=1;i<=16;i++)
{
int scale = w/((10)^i);
if (scale<10 && scale>0)
{
int length = i+1;
printf("%i\n",length);
}
}
}