-1
這是我的代碼中的一個函數,我確定計數循環是導致我的程序中斷的原因。計數函數無限循環。怎麼修?
第一個打印語句將返回代碼中較早設置的數字,但它從不打印下一個打印語句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);
}
+1好,這是一個很難看到的。 – 2013-03-24 18:24:26
aaaaahhh dang it! – 2013-03-24 18:25:27
感謝哈哈,做到了! – 2013-03-24 18:26:04