1. Using the compiler to convert the code in the source file into binary code, this process is called compiling.
Switch the work path of the terminal to the path where the source file resides.
Cc-c the name of the source file. Example: Cc-c main.c
If there is no accident, an. o file is generated under the current working path, which is called the target file.
The destination file stores the binary instructions that correspond to the code in the. c file.
2. The target file only stores the binary instructions that correspond to the code in the. c file.
If a program wants to give the CPU execution, the light does not work.
You must also add some startup code for this target file. The process of adding a startup code is called a link.
CC target file name. Example: CC MAIN.O
If everything is normal, a a.out file is generated. This file is the final program that can be executed.
3. Execute the A.OUT program and you will see the results of the program execution.
./a.out
Compile and run C code under MAC OS x system