1. First determine whether to install the gcc compiler under Linux, directly execute: gcc -v to determine whether to install gcc. (Recommended learning: linux operation and maintenance)
2. Then you need to write a simple C source program in the code box .
#3. The mathematical square root function in C language, sqrt(), is used in the program, so the math.h header file needs to be introduced.
#4. After writing the source program, we compile it. If we use the usual compilation statement, [gcc math.c -o math] to compile, there will be Error; it probably means that you don’t know sqrt.
5. Therefore, needs to use the correct command: [gcc math.c -lm -o math]; only in this way can the compilation be correct.
The above is the detailed content of How to write c language in linux. For more information, please follow other related articles on the PHP Chinese website!