------Java Training, Android training, iOS training,. NET training, look forward to communicating with you! -------
The following is their own learning summary and study notes, there may not be a comprehensive place, but also welcome everyone to share.
The C language is one of the most popular and widely used high-level programming languages in the world, and its main uses include
1, write system software, graphics processing, microcontroller program, embedded system development
2, write the game plug
3. Writing android programs
4. Write iOS Programs
any C language program is composed of one or more program sections, and these have their own function of the program section is a function, speaking of functions, we have to mention the main function, the main function seems to be in the computer language is a regular, previously learned C++,java, Maybe this is where the computer language communicates. The C language program executes, first through the main function, and only executes the main function.
The main function calls other functions, and the printf function outputs information to the screen, #include <stdio.h> calls the system's own function.
In the C language executes the program is: 1, writes the code 2, compiles, namely uses the Clang compiler compiles the code to the computer to be able to recognize 0 and 1 (instruction: cc-c) to generate. o file 3, link, that is, the. O's target file is merged with the system's own library to generate an executable file (linker, directive: CC File name. O)
Note: Compilation checks that the syntax is correct and does not control whether the program is functioning properly. The link will take into account whether the program will run correctly (there is a main function)
One, the scope of variables
The scope of a variable is the beginning of the line of code that defines the variable and the end of the function.
1#include <stdio.h>2 3 intTest ()4 {5 intA = -;//variable A is defined in the test function, and the scope is ended in the test function6 return 0;7 }8 9 intMain ()Ten { One test (); AA = $;//It's not going to work. Variable A is scoped from the definition to the end of the test function, and the variable A in the test function is inaccessible . - return 0; -}
As the study progresses, the scope of the re-understanding variable begins with the line of code that defines the variable, until the end of the block of code that is being used, and the code block is in time to reclaim some of the variables that are no longer in use in order to improve performance.
An example of a variable's scope problem:
1#include <stdio.h>2 intMain ()//multiple blocks of code in the main function3 {4 intA = -;5 intScore = a + -;6printf"%d\n", score);//Output7 8 {9 intScore = -;Ten { OneScore =Ten;//The variable score is not defined in this code block, so it looks in its outer code block and assigns its value to a value of ten. Aprintf"%d\n", score);//output here. - } -A =Ten;//As above , assign a value of a in the outer code block to the } - - { -Score = a + -;//The upper block of code is destroyed, a=10, so the score in the outer code block is now assigned the value 260. + intScore = -; -printf"%d\n, score");//here the nearest output + } Aprintf"%d\n", score);//Although the upper block of code has been destroyed but assigned a value of score to 260, the output 260 is here. at return 0; -}
Dark Horse programmer-learning of Basic grammar of C language