C-Functions, array pointers, operations between pointers

Source: Internet
Author: User
Tags goto tag name

Goto principle: When executed to the GOTO statement, the CPU will jump to the current function to specify the flag where the use of Goto can also be used to achieve loop operation but in use, be careful not to cause a dead loop in general, it is not recommended to use the Goto statement frequently, because it is unsafe--it easily causes a dead loop. The goto can only be used unless it is specifically determined that there is no dead loopGoto not only can jump forward, but also can jump back to use Goto, the next line of code line of the tag code can not be declared variable, if not to write in this place, then the declaration of variable line in front of a meaningless code identifier: Popular is the programmer can name things: variable name, goto tag name, Function name and other face questions 3
 for (int0; i<; i++ ) {    for (int0; j<10 ; J + +)        {// use a piece of code to jump out of the outer loop        ;          Break     }}
Function: You can implement code reuse, the function only needs the first time, then the code in the function can use the function of Note: 1. The position of the function: the outer global variable of the main function is initialized with the local variable 1. Local variables: Uninitialized, is a random number 2. Global variables: If it is a numeric value, it is initialized to 0 by default, and if it is char, it is initialized to '/', which is the 0 creation time in the ASCII code 1. Local Variables: When you run to the declaration statement, it will be created, and the scope will be recycled 2. Global variables: The program is created when it is run. The features of the global variable are recycled at the end of the program:
1 int Ten ; 2 int Main () {3     printf ("%d\n", num);  // here is the access to the global 4     int Ten ; 5     // here is the local 6 }

Parameters of the   function 1. Declare the variable in parentheses after the function name, and we'll call it the function's arguments   The relationship of the argument: the assignment  return can be either with a constant or with an expression   when the return expression is   Return is the result of the expression   about the declaration and definition of the function: 1. If the function writes a declaration, then the definition of the function can be placed behind the calling function  2. The declaration of the function is to be placed at the latest before the function call, usually written at the top of the  3. If the function is tuned before the keynote function, this time, the declaration of the function can be omitted, write the definition directly, if the definition of the called function is behind the keynote function, then this time must be declared before the call function  4. The function of declaring functions is cast, Must be consistent with the function head that implements the function (arguments can be inconsistent, except that the return value or result is disorganized)  5. When declaring a function, the name of the parameter can be omitted (but strongly recommended for unification) if the function has parameters,  6. If the return value of the function is of type int, Can not write the declaration, because the default is the type of int (but will give a warning, so still want to write)  -=-=-=-=-=-=-function writing specification-=-=-=-=-=-=-1.main function in any case in the first place 2. No matter what, function to write declaration and implementation declaration at the top, #include the following implementation is written after the main function 3. Declaration and Implementation consistency   the operation between pointers why is there no addition between the two pointer variables? and multiplication and division 1. If you add, you may cross the line after the addition. The address bounds of the array are exceeded and overflow 2. Multiplication   Effect: 1. Determine whether the variable that the two pointer is pointing to is the same, and if so, the result of the subtraction is 02. Determine if the variable that the two pointer points to is adjacent, and if so, the result of the subtraction is positive and negative 1   The relationship between two pointer variables (p1, p2) operation P2 > P1 result equals 1     P2 in high position result equals 0 P1 at high position, or point to same element   two dimensional array with pointer has two dimensional array int array[][] = {{1,3,5,7 },{9,11,13,15},{17,19,21,23}} is easy to get: Array[0] is the first element of the first row, and also the first line's first address reasoning can be: array[0]+1, array[0]+2, Array[0]+3 is the first row of the 2nd, 3, 4 element Conventions: Array[0], Array[0]+1, array[0]+2, array[0]+3 is a column pointer in a two-dimensional array   easy to get: The first address of the first row is an array, so reasoning can be: Array+1 is the first address of the second row array+2 is the first address of the third row   Conventions: Array, array+1, array+2 are row pointers    array pointers in two-dimensional arrays: Define a pointer variable that points to the element of a one-dimensional array   Two-dimensional array pointers: Row pointers: Used to point to each row of a two-dimensional array, The first address form of the row is stored: data type (* pointer variable name) (length of second dimension of array)   initialization of two-dimensional array pointers
1 inta[2][3];2 intb[2][2];3 floatf1[4][4];4 //Suppose you want to define a row pointer to array a5 int(*PA) [3] = a[0];//a[0] = = = &a[0] ==&a[0][0]6 7 //use of two-dimensional arrays8* (* (p+i) +j)//get each element of a two-dimensional array

C-Functions, array pointers, operations between pointers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.