Send a simple question to test your understanding of the details of the C language

Source: Internet
Author: User
I am sending a simple question to test everyone's understanding of the details of the C language-General Linux technology-Linux programming and kernel information. The following is a detailed description. What are the output results of the following code after compilation and running? Same. or diff? The answer is not written in the post. you 'd better run it. if you find that the result is inconsistent with your previous inference, you 'd better add a few breakpoints to see what happened in the memory...

# Include
# Include
# Include

/* On a 32-bit machine */

Typedef struct
{
Char CR;
Long lVal;
} TDATA_S;

Int main ()
{
TDATA_S stDat1, stDat2;

Memset (& stDat1, 0, sizeof (TDATA_S ));
Stdat2.cr = 0;
StDat2.lVal = 0;

If (memcmp (& stDat1, & stDat2, sizeof (TDATA_S) = 0)
{
Printf ("same. \ n ");
}
Else
{
Printf ("diff. \ n ");
}

Return 0;
}

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.