当前位置:网站首页>Standard C language learning summary 3

Standard C language learning summary 3

2022-07-28 07:07:00 c7473168

Jump statements

    goto

        You can jump anywhere in the function

        Tag name :

            ...

            goto Tag name ;

        It may break the designed branch or loop structure , Therefore, most companies prohibit the use of goto

        But it is especially suitable for handling exceptions in driver programming

    break

        1、 stay switch Closed in case Execute the switch

        2、 Out of the loop , You can only jump out of the current layer of loop

    continue

        End this cycle , Enter next cycle

    return

        1、 End function execution , The program jumps back to the place where the function is called and continues to execute

        2、 Return a data to the caller of the function

Array

    What is an array : The combination of variables , It is a way to define variables of the same type in batch

    Definition : Type name Array name [ Number ];

            int arr[5];

    Use : Array name [ Subscript ];

            Subscript : Starting from scratch Range : 0~ Number -1

                arr[0] = 10  arr[4] *10

    Traverse : And for Circular fit , Use a circular variable as the subscript of the array

    initialization : Type name array name [ Number ] = {1,2,3,4...};

An array :    

    For program compilation , The efficiency compiler does not check the subscript of the array

    Consequences of array out of bounds :

       /* 1. Segment error ( The core has been dumped )

        2. Everything is all right

        3. Dirty data */

    summary : In the process of using arrays , Always be careful not to cross the line

Two dimensional array :

    A one-dimensional array is equivalent to arranging variables in a row , Access by number

    A two-dimensional array is equivalent to arranging variables into

     Traverse : Need and double-layer for Circular fit , The outer loop is responsible for traversing rows , The inner loop traverses a matrix , Access through row and column numbers

Variable length array :

    When defining an array, use variables as the length of the array , The length of the array is uncertain during code compilation ,

    The length of the array is finally determined when the definition statement of the array is run , This kind of array is called variable length array

    Be careful : Once the length is determined , It can't be changed later

    advantage : The length of the array can be determined according to the actual situation , In order to save memory space

    shortcoming : Unable to initialize , Because initialization occurs during program compilation

原网站

版权声明
本文为[c7473168]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280517003995.html