我以前编译过其他程序,但由于某种原因,我不能再工作了。我有一台 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.
我是编码的初学者,不知道该怎么做。
最佳答案
我假设您希望输出文件是average
?然后使用这个:
gcc average.c -o average
关于c - 编译 C 程序时,出现此错误 : hello: no such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17792702/