Compiled int32_t for 64-bit Linux systems

Source: Internet
Author: User

Compile and execute under 64-bit Linux system the output of the program is

40 8

#include <stdio.h> #include <stdlib.h> #include <stdint.h>void print_size (int32_t array[10]) {printf ("%ld\n", sizeof (array));} int main () {    int32_t myarray[10];    printf ("%ld\n", sizeof (myarray));    Print_size (myarray);    return 0;}
Int32_t,int64_t is a pre-defined type of C language to be able to run the program uniformly in different systems, and it is included in the header file stdint.h. They are all int types, except that their bytes remain the same in different systems, for example: int32_t occupies 4 bytes in a 32-bit system, and still accounts for 4 bytes in 64-bit systems. This ensures that the same bytes are consumed in different systems. The specific conversion process does not need to be considered, interested students can go to the head file to see. Int64_t the same truth.
For the above program is compiled on a 64-bit Linux system to run, so int32_t is still bit 4 bytes, so the first result of printing is 40, however, when the function is called the address, the address in the 64-bit system occupies a byte 8 bits, so the result of the second printing is 8.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Compiled int32_t for 64-bit Linux systems

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.