c - 编译 C 程序时,出现此错误 : hello: no such file or directory

标签 c macos gcc

我以前编译过其他程序,但由于某种原因,我不能再工作了。我有一台 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/

相关文章:

C:通过指针设置结构的数组成员

c - 用于简单固定(多)精度运算(add、div、mul、sub)的快速 C 代码?

swift - NSProgressIndicator 无法在带有回调的函数内部工作

xcode - NSMutableAttributedString设置字体大小

c++ - GCC 匿名未初始化

C: Scanf 验证

c - 为什么返回指针不能赋值给指针,数组其实不是指针?

Java Robot Keypress 命令键

c++ - 是 GCC 错误吗?

c - 编译 BASIC "libnotify"代码时出错