C examples for Data Type:sizeof
You can find out how many bytes are occupied for a given type by using the sizeof operator.
Here's how you could store a value that results from applying the sizeof operator:
size_t size = sizeof(long long);
This program will output the number of bytes occupied by each numeric type:
#include <stdio.h> int main(void) { printf("Variables of type char occupy %u bytes\n", sizeof(char)); printf("Variables of type short occupy %u bytes\n", sizeof(short)); printf("Variables of type int occupy %u bytes\n", sizeof(int)); printf("Variables of type long occupy %u bytes\n", sizeof(long)); printf("Variables of type long long occupy %u bytes\n", sizeof(long long)); printf("Variables of type float occupy %u bytes\n", sizeof(float)); printf("Variables of type double occupy %u bytes\n", sizeof(double)); printf("Variables of type long double occupy %u bytes\n", sizeof(long double)); return 0;/* ww w .jav a 2s . c om*/ }