我個function call 有乜問題

提示: 作者被禁止或刪除 內容自動屏蔽

原帖由 so3fate 於 2008-11-11 00:18 發表
#include
int count_digit(int w);

int main()
{
   int x;

printf("Please enter a positive integer(maximum 8 digits):");
scanf("%d",&x);
printf("The number entered is %d\n",x);


if (x >0 && x0)
{
   ...


你試下用"人類語言"講解下你想做乜野?

TOP

while (v>0)
{
         counter=counter+1;
         v=v/10;

         return(v);
}


should be


while (v>0)
{
         counter=counter+1;
         v=v/10;
}
return counter;

TOP

原帖由 Tony仔 於 2008-11-11 01:23 發表
while (v>0)
{
         counter=counter+1;
         v=v/10;

         return(v);
}


should be


while (v>0)
{
         counter=counter+1;
         v=v/10;
}
return counter;


你咁快開估佢學唔到野架.

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

原帖由 so3fate 於 2008-11-11 01:44 發表

試完,佢話我未initialize v??
但我唔可以initialize wor
其實我咁return function 有冇問題
因為user 會input x
而v 只是function , 唔係x 個value.....=.=


點解你認為唔可以initialize v 呢?

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

原帖由 so3fate 於 2008-11-11 01:51 發表

initialize左就會violate user input


為什麼呢?

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

原帖由 so3fate 於 2008-11-11 01:56 發表

呢個programme 我define 左 x
咁user enter XXXXXXXX 8 digits

我開左個function find the number of digits
咁如果v intialize 左,可能會affect 到X


你有無真係試過呢?

TOP