View the number of bytes occupied by the Keil MDK-ARM for various data types

Source: Internet
Author: User

1. Define several variables to store the number of bytes of each data type.

# Include <stdio. h>

Unsigned char a, B, c, d, e, f, g;

Main ()


A = sizeof (char );

B = sizeof (short INT );

C = sizeof (INT );

D = sizeof (long );

E = sizeof (long INT );

F = sizeof (float );

G = sizeof (double );

While (1 );


2. view the storage address of each variable. View --- symbols window.

3. view the stored values of each address. View --- Memory window.

Char occupies 1 byte

Short int occupies 2 bytes

Int occupies 4 bytes

Long occupies 4 bytes

Long int occupies 4 bytes

Float occupies 4 bytes

Double occupies 8 bytes

We can define the macro as follows:

typedef unsigned char uint8; // unsigned 8-bit integer variable
typedef signed Char int8; // signed 8-bit integer variable
typedef unsigned short uint16; // unsigned 16-bit integer variable
typedef signed short int16; // signed 16-bit integer variable
typedef unsigned int uint32; // unsigned 32-bit integer variable
typedef signed int int32; // signed 32-bit integer variable
typedef float fp32; // Single-precision floating point number (32-bit length)
typedef double fp64; // double-precision floating point number (64-bit length)

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: 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.