本文介绍了编译一个C程序时,我得到这个错误:hello:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我之前编写过其他程序,但由于某种原因,我再也无法工作了。我有一个mac这是我的代码。它的目的是获取三个数字并找到平均值。
I have compiled other programs before but, for some reason, I can't work anymore. I have a mac Here's my code. Its purpose is to take three numbers and find the average.
#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。我打开终端并键入
These are the steps I have taken. I put average.c and average.h on the desktop. I open terminal and type
cd Desktop
gcc /Users/reneelion/Desktop/average.c average
然后它说:
Then it says:
average: No such file or directory.
我是一名编程初学者,不知道该怎么做。
I am a beginner at coding and don't know what to do.
推荐答案
我假设你希望输出文件是 average
?然后使用这个:
I assume you want the output file to be average
? Then use this:
gcc average.c -o average
这篇关于编译一个C程序时,我得到这个错误:hello:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!