在Linux中,要编译并运行一个C文件,你需要先确保已经安装了GCC(GNU Compiler Collection)
cd命令导航到包含C文件的目录。gcc -o output_file input_file.c 其中,input_file.c是你的C源代码文件,output_file是你想要生成的可执行文件名。例如,如果你的文件名是hello.c,你可以使用以下命令编译它:
gcc -o hello hello.c 这将生成一个名为hello的可执行文件。
./output_file 将output_file替换为你在上一步中生成的可执行文件名。例如:
./hello 这将运行名为hello的可执行文件。