How to compile and run C code in Linux system

Step 1:
Open the terminal and enter vim hello.c to create a new C code.
Step 2:Insert picture description here
The command "vim" is prompted, so we follow the prompts below to download and enter "sudo apt install vim".
Insert picture description here
*At this time you may encounter such trouble: Why can't I enter the password? Why is the entered password only in English and no digital display? Don’t worry, this is the Linux power-on password, and the password will not be displayed if you enter it. If your computer has a small keyboard, make sure that it is not locked. It is best to use the main Enter the number on the keyboard and press Enter after the last key. Then slowly wait for the download to complete (it's quite slow).
The third step:
input vim once.c, it will become like this: Insert picture description here
wait a while, when insert appears, enter the main body of the code, such as
#include<stdio.h>
int main()
{printf("hello!");
return 0;
}
Then press the ESC key, enter wq to save and exit
. Step 4:
You can check if there is a new "once.c" file. You can use the ls command to view it.
When typing gcc once.c to compile, it is found that there is less I downloaded a gcc package, then follow the instructions to download and install the package, retype gcc once.c, and you can see the results of the operation.

Guess you like

Origin blog.csdn.net/qq_43511299/article/details/107910362