Ubuntu19.10 compile and run C language program

Ubuntu19.10 comes with gcc, if you don’t have one, install the gcc compiler first:

sudo apt install build-essential

Create a C language program file:

vim Hello.c

Enter the code, whatever you want, just run it:

# include <stdio.h>
# include <math.h>
 
int main(){for( float y =1.3; y >=-1.1; y -=0.06){for( float x =-1.2; x <=1.2; x +=0.025){if(pow((x*x+y*y-1.0),3)- x*x*y*y*y <=0.0)printf(" ");elseprintf("*");}printf("\n");}return0;}

Next compile the file:

gcc -o Hello Hello.c -lm

- o is to determine the name of the output file, the first Hello is the name of the output file, which can be customized.
- The lm option tells the compiler that the mathematical functions used in our program should be found in this library file.

Attach the meaning of commonly used parameters:

lc is link libc
lm is link libm
lz is link libz

After the compilation is complete, enter the execution command:

. /Hello

Can output:

Recommended Posts

Ubuntu19.10 compile and run C language program
Ubuntu 16.04 compile and install PHP 7.2
ubuntu18.04 compile and install python3.8
Compile and install QEMU under Ubuntu
Linux development preparation-install VMware and run Ubuntu
51 MCU program development and download under Ubuntu
Ubuntu 18.04 source code compile and install ffmpeg4.1
Linux install Docker and run Ubuntu system
Compile and install OpenJDK8 from source code under Ubuntu 18.04.1
Summary: Ubuntu Python2.x and
Ubuntu20.04 experience and beautification
Ubuntu introduction and installation
[python] python2 and python3 under ubuntu
Ubuntu backup and restore
How to compile and install PHP and Nginx in Ubuntu environment