C language basic data type size

Source: Internet
Author: User

The number of bytes consumed by the C basic data type can be obtained by the following example:

#include <stdio.h>intMainvoid) {printf ("char size=%d \ n",sizeof(Char)); printf ("int size=%d \ n",sizeof(int)); printf ("long size=%d \ n",sizeof(Long)); printf ("float size=%d \ n",sizeof(float)); printf ("double size=%d \ n",sizeof(Double)); printf ("char* size=%d \ n",sizeof(Char*)); printf ("int* size=%d \ n",sizeof(int*)); printf ("long* size=%d \ n",sizeof(Long*)); printf ("float* size=%d \ n",sizeof(float*)); printf ("double* size=%d \ n",sizeof(Double*)); printf ("char[] size=%d \ n",sizeof(Char[2])); return 0;}

Execution Result:

$./size.exe
Char size=1
int size=4
Long size=8
Float size=4
Double size=8
char* size=8
int* size=8
long* size=8
float* size=8
double* size=8
Char[] size=2

Above, unit is byte, one byte is 8 bit

It is important to note that any type of pointer variable occupies 8 bytes

C language basic data type size

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.