C language Statements
1. Empty statement: When an If or while judgment part can complete the work, an empty statement can be used to represent the if or the empty loop body in the while
1 if(a = = B);
2.GCC compiler
1 //the process of compiling the program:2 //pretreatment: pre-processing3 //Compiling: Compiling4 //Compilation: Assembling5 //Links: Linking6 7 //preprocessing phase: *.c or *. The C file is preprocessed into a *.i file, which mainly handles #ifdef #include #define8Command: GCC-E test.c-o test.i9 Ten //compile Stage: input *.i file, compile and build assembly file *.s OneCommand: Gcc-s test.i-o test.s A - //Assembly phase, turn *.s into *.o binary file -Command: Gcc-c TEST.S-o test.o the - //link stage: Aggregating *.O binaries into an executable file -Command: GCC TEST.O-o Test - + //the above process can be summarized as: -Command: Gcc-c test.c-o test.o +GCC TEST.O-o Test A or: atGCC Test.c-o Test
3.GCC common options;
1 // compile multiple *.c files at the same time 2 command: gcc-o test file1.c file2.c file3.c3// three files compile and generate test executable file , note that only one of the three files can have a main function, and if you are compiling only the target file, there is no main function.
4.GCC most basic usage:
1 //-C compiles only, does not connect to executable files2 //-o output_filename determine the file name of the output3 //- g to generate the debugger gdb must be the symbol, to debug the source code, you must compile the time to add this parameter4 //-O optimizes the compilation connection for the program, but the compilation is relatively slow5 //-o2 better compile than-O, but the build connection will be slower6 //-wall Output all warning messages7 //-W Turn off all warnings, we recommend that you do not use this option8 //Idirname, adding a directory named Idirname to the program header file directory list, the options used in the preprocessing phase9 Ten //the C language header file will be heavily used, usually composed of header files and definition files. One //The header file contains the function prototype declaration, the constant definition of the file, the declaration used to save the program A //the definition file is used to save the program's implementation implementation. - //header file with. h as suffix -#include <stdio.h>//go to the system preset include file directory to find general system-provided header file system presets include directories for/usr/include the#include"stdio.h" //first to the current directory to find, and then to the designated Idirname to find their own writing is generally placed in the current directory, large programs will be unified in a directory - - //-l DIRNAME The parameters that are used in the connection process by adding directories named DirName to the search directory of the library file.
5. The system provides two types of libraries: static libraries and dynamic libraries
GCC Default library file storage directory/usr/lib
6 Questions:
1. Write the statement of float vs. 0 comparison
1 //the problem of float accuracy cannot be written as:2 if(x = =0.0);3 if(X! =0.0);4 //should be written as:5 if(x >=-0.00001&& x <=0.00001);6 7 //Do not use the floating-point variable = = or! = Compare, try to convert into <= and >=
2.switch conditions must be integer and Char
3.for (; 1;) is a dead loop
Linux C Program (SIX)