Summary-C language-pointer

Source: Internet
Author: User

Summary-C language-pointer

1. embedded systems often have requirementsProgramUsers access the features of a specific memory location. In a project, it is required to set the value of an integer variable with the correct IP address 0x67a9 to 0xaa66. the compiler is a pure ANSI compiler that writes a code to complete this task.

Note: Whether you know that it is legal to forcibly convert an integer (ypecast) into a pointer to access an absolute address,

Answer:

Int * PTR;

PTR = (int *) 0x67a9;

* PTR = 0xaa66;

A relatively obscure method is:

* (Int * const) (0x67a9) = 0xaa66;

Even if your taste is closer to the second solution, I suggest you use the first solution during the interview.

2.

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.