Home > Operation and Maintenance > Linux Operation and Maintenance > How to run c program commands in linux

How to run c program commands in linux

coldplay.xixi
Release: 2023-01-03 09:23:34
Original
39645 people have browsed it

How to run c program commands in Linux: First open the terminal of kali linux, use the vim tool to open the file and write code; then enter [gcc test.cgcc] to compile; finally run [test.out] in Enter [./test.out] in the terminal.

How to run c program commands in linux

The operating environment of this tutorial: linux7.3 system, DELL G3 computer.

How to run c program commands in linux:

1. Open the terminal of kali linux. Create a file and name it test.c. Enter: touch test.c in the terminal.

How to run c program commands in linux

#2. You can see that a source file with the suffix test.c has been generated. Then open this file with vim tool and write code. Enter: vim test.c or gvim test.c in the terminal to open this file and write the code.

How to run c program commands in linux

#3. Finished writing this code. Now start compiling the source files. Enter in the terminal: gcc test.cgcc is the C language compiler that comes with Linux. If it is Windows, you need to use IDE tools to compile. Linux systems generally use the three built-in tools gcc vim gdb to write C language.

How to run c program commands in linux

#4. Complete gcc test.c and compile the C source file. Then you can see the a.out file. Generally, Linux systems default to a.out as the compiled file. Now run the a.out file. Open the terminal in the directory of the a.out file and enter ./a.out to run the file.

How to run c program commands in linux

#5. If you want the compiled file name, do not use the a.out file. You can type .gcc test.c -o test.out during compilation and then you can see there is a test.out. file. The file name generated by compilation followed by

-o.

How to run c program commands in linux

6. Run test.out again and enter ./test.out in the terminal. The result is as shown in the figure. In this way, compiling and running C language under the Linux system is completed.

How to run c program commands in linux

Related learning recommendations: linux video tutorial

The above is the detailed content of How to run c program commands in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template