495 C-language questions you must know notes

Source: Internet
Author: User

1.10 What assumptions can be made about the initial value of a variable that is not initialized? If a global variable has an initial value of "0", can it be a null pointer or a floating-point zero?


Uninitialized variables that have a "static" lifetime (that is, variables declared outside the function and variables with static storage types) can ensure that the initial value is zero , just as the programmer types "= 0". Therefore, if the pointer is initialized to the correct null pointer, the floating-point number is initialized to 0.0 (or
See chapter 5th) for the correct type.
Variables that have an "automatic" lifetime (that is, local variables that do not have a static storage type) contain junk content if they are not initialized with a display. You cannot make any useful assumptions about the content of the garbage. These rules also apply to arrays and structures (called "aggregates"); For initialization, arrays and nodes
are considered to be "variables".
Memory allocated dynamically with malloc () and ReAlloc () may also contain garbage data, so it must be properly initialized by the caller. The memory obtained with CALLOC () is all zeros, but this is not necessarily useful for pointers and floating-point values (see Questions 7.26 and 5th).

495 C-language questions you must know notes

Related Article

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.