我以前编译过其他程序,但由于某种原因,我不能再工作了。我有一个 mac 这是我的代码。它的目的是取三个数字并找到平均值。
#include <stdio.h>
int main(){
int first;
int second;
int third;
float average=0.0;
printf ("This program will find the average of 3 numbers.\n");
delay(1000);
printf ("Type the first number.\n");
scanf ("%d", &first);
printf ("Type the second number.\n");
scanf ("%d", &second);
printf ("Type the third number.\n");
scanf ("%d", &third);
average = (first+second+third)/2.0;
printf ("The average of %d, %d, and %d is %.3f\n", first, second, third, average);
return (0);
}
这些是我采取的步骤。我把average.c和average.h放在桌面上。我打开终端并输入
cd Desktop
gcc /Users/reneelion/Desktop/average.c average
然后它说:
average: No such file or directory.
我是编码初学者,不知道该怎么做。