Home > Article > Operation and Maintenance > How to run c program commands in linux
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.
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.
#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.
#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.
#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.
#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.
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.
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!