#include<stdio.h>
int main() {
int m,n;
float cake;
printf("Enter total kgs of cake:");
scanf("&d", &n);
printf("Enter the number of friends:");
scanf("&d", &m);
cake = m/n;
printf(He has to distribute %f kg cake to each of his %d friends",
&cake, &m);
}
當我運行這個程序中的代碼塊,它要求我只進入蛋糕的總公斤,當我進入它,點擊進入,程序只是打印一切在下面的printf函數而不是要求我輸入朋友的數量。C程序輸出錯誤
'scanf(「%d」,&n)'。我想知道編譯器如何忽略它。 –
這不是我第一次看到'&d'而不是'%d'的問題。 –
@RohanKumar:'printf(他必須向他的每個%d朋友分發%f kg蛋糕「,&蛋糕,&m);'它甚至沒有編譯(開始時缺少報價) –