为什么在这里发生“被零除”?

问题描述 投票:0回答:1

我一直在尝试使用该程序查找给定数字的长度,但是每次运行它都会收到以下错误:

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);
            }
       }    
}
c runtime-error cs50 divide-by-zero
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.