How to run c program command in linux

The method of running the c program command in linux: first open the kali linux terminal, open the file with the vim tool and write the code; then enter [gcc test.cgcc] to compile; finally run [test.out] and enter [./ test.out].

The operating environment of this tutorial: windows7 system, linux7.3 version, DELL G3 computer, this method is applicable to all brands of computers.

How to run c program command in linux:

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

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

3. Finish writing this code. Now compile 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 the ide tool to compile. The linux system generally writes in C language and uses the three built-in tools of gcc + vim + gdb.

4. After typing gcc test.c, compile the C source file. Then you can see the a.out file. Generally, the Linux system defaults 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. Do not use the a.out file if you want the compiled file name. You can enter .gcc test.c -o test.out at compile time and then you can see that there is a test.out. file.

-o followed by the compiled file name.

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 the C language under the linux system is completed.

Related learning recommendation: linux video tutorial

Guess you like

Origin blog.csdn.net/Ajekseg/article/details/126433652