Consortium/community Union

Source: Internet
Author: User

Defining a community is similar to defining struct.

First, define a struct:

Typedef struct

{

Unsigned char floor;

Unsigned char room;

Unsigned short region;

} Position;

 

Define another community

Typedef Union

{

Position lightpos;

Unsigned char posbyte [4];

} P;

 

If the values are as follows:

P. lightpos. Floor = 0x10;

P. lightpos. Room = 0x01;

P. lightpos. region = 0x0501;

 

Then:

P. posbyte [0] = 0x10;

P. posbyte [1] = 0x01;

P. posbyte [2] = 0x01;

P. posbyte [3] = 0x05;

 

That is to say, all members of the community share the memory. When one member is assigned a value, the value of the other member changes accordingly.

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.