计数函数无限循环.怎么修?

-1 c++ loops infinite

这是我的代码中的一个函数,我知道count循环是导致我的程序中断的原因.

第一个print语句将返回代码中先前设置的数字,但它永远不会打印下一个print语句hello.

我不知道为什么它不起作用.有人能帮我吗?

//Function Declaration
int calc_digits(int number)
{
 //Local Declaration
  int count = 0; // the times the loop has ran

  printf("%d", number);
  fflush(stdout);

  while (number != 0);
   {
     number /=  10;
     count++;
   }
 printf("hello");
 fflush(stdout);
 return(count);
}
Run Code Online (Sandbox Code Playgroud)

Tri*_*mon 9

这是错误:

while (number != 0);
Run Code Online (Sandbox Code Playgroud)

你的while循环在这里结束:-)

你应该删除;这一行.