简体   繁体   English

我在编译和运行C程序时遇到问题。 命令是什么?

[英]I am having trouble compiling and running my C program. What are the commands?

I am having trouble compiling and running my C program. 我在编译和运行C程序时遇到问题。 What are the commands? 命令是什么?

My code is: 我的代码是:

#include <stdio.h>
int main(){
   printf("Hello World!\n");
   exit(0);
}

I tried compiling with 我尝试用

gcc -o hello.c

only to be unsuccessful. 只是不成功。 I am using a Mac terminal, if that matters. 如果这很重要,我正在使用Mac终端。

In gcc , option -o is used to specify a custom output filename. gcc ,选项-o用于指定自定义输出文件名。 The immediate next argument should be the file name. 下一个直接参数应该是文件名。

-o file

Place output in file file. 将输出放置在文件文件中。 This applies to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code. 这适用于所产生的任何类型的输出,无论是可执行文件,目标文件,汇编文件还是预处理的C代码。

A simple revised command will be 一个简单的修订命令将是

gcc -o hello hello.c 

where, hello is the name of the binary. 其中, hello是二进制文件的名称。

You can check the online gcc manual for more info. 您可以查看在线gcc手册以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我在程序中读取文件有困难。 我是否正确使用for循环读取文件? - I having difficulty reading the file in my program. Am I using the for loop correctly to read the file? C程序正在编译并运行,但是我在终端中得到了一个奇怪的输出 - c program is compiling and running but I am getting a weird output in the terminal 我的C程序出现几个错误。 请帮我解决我做错的任何事情 - I am getting a couple errors with my C program. Please assist me with whatever I am doing wrong 我的 C 语言二进制堆程序有问题 - I am having a problem with my binary heap program in C 我的 C 程序中的 function 出现问题。 程序在执行“encript()”function 中的倒数第二个“printf()”之前终止 - Having a problem with a function in my C program. Program terminates before executing the second last “printf()” in the “encript()” function 什么是退出值 5,为什么我在运行 C 程序时不断收到此错误? - What is exit value 5 and why am I keep getting this error while running my C program? 在我的C程序中遇到结构和数组问题 - Having trouble with structures and arrays in my C program 我在 C 上遇到 OpenMP 问题 - I am having trouble with OpenMP on C 我无法理解 C 中的 -> 运算符 - I am having trouble understanding the -> operator in C 我在C中使用sscanf有麻烦 - I am having trouble using sscanf in C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM