Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Assignment of static storage array in c language.
Assignment of static storage array in c language.
Use static to define a static array, which will exist in the whole life cycle of the program, and this array will be allocated and placed in. The bss segment of the program, in which all data will be automatically initialized to 0. If it is declared in a function, the array used every time this function is called is the same array. If it is not defined in the function, this array can only be used in this file.

If there is no array declared by static, this array will be allocated in the stack frame that calls this function, that is, allocated on the stack, and this array will not be initialized. The values in the array are random. If it is defined in a function, the array used each time this function is called is generally different.

As for whether to use static to declare, on the one hand, it depends on whether you need this array to be used for a long time, on the other hand, it depends on whether it needs to be automatically initialized to 0, and on whether it needs to be used in other files.