About the C language: initializing a pointer variable to an array why don't I need the & symbol?

Source: Internet
Author: User

The name of the array in C is the address of the first element, so you can assign it directly to a pointer without having to take an address.

1  void Initbitree (sqbitree T) 2  // constructs an empty binary tree T. Because T is an array name, it does not need &3    int  i; 4     for (i=0; i<max_tree_size;i++) 5      // Null value (nil is defined in the main path) 6  }

In the above initialization code, T is an array name, which also represents the first address of the array, which is an address and does not require an address character.

It's not the same as the bottom initialization.

1  void Initstring (HString &T)     2   //  Initialize (generate empty string) of string T.  3     t.length=5; 4     T.ch="hhhhh"; 5   }6  

The resulting string T is not an address, so you need to add the address character to initialize the string T and change its internal value. If not added, only in this function when the main function is executed, in memory to allocate another piece of storage to store, when the function is finished, the memory is allocated will be retracted, there is no change in the original string value.

About the C language: initializing a pointer variable to an array why don't I need the & symbol?

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.