Run C language code in the virtual machine Linux

1. Open the virtual machine terminal

2. Switch to administrator status

import su

(If it prompts that the authentication fails, enter sudo passwd root)

3. Enter the statement to download the compiler:

sudo apt-get install vim  
sudo apt-get install gcc

(If the lock cannot be obtained, enter sudo rm /var/cache/apt/archives/lock )

 Enter y to continue:

4. Enter vi hello.c

Write code in the newly pop-up vim editor window: enter i to insert

Press Esc to exit insert mode, enter :wq   to save and exit

 5. Enter  gcc hello.c -o hello

             ./hello

The first line: compile hello.c into an executable file target hello

The second line: execute the file

 

Guess you like

Origin blog.csdn.net/m0_57781693/article/details/130539145