C program to know storage size of int, char and float

To get the exact size of a type or a variable on a particular platform, you can use the sizeof operator. The expressions sizeof(type) yields the storage size of the object or type in bytes. Following is an example to get the size of int type on any machine.

 $ vim know_size.c 
#include <stdio.h>
#include <limits.h>
int main(int argc, char **argv) {
        printf("Storage size for int : %d \n", sizeof(int));
        printf("Storage size for char : %d \n", sizeof(char));
        printf("Storage size for float : %d \n", sizeof(float));
        return 0;
 $ gcc -o know_size know_size.c 
 $ ./know_size
Storage size for int : 4 
Storage size for char : 1 
Storage size for float : 4 
Payroll Management System in C Lang... x
Payroll Management System in C Language with Source Code | C Projects with Source Code

Leave a Comment

Sign up to our newsletter!

ADB Commands Android Android Applications Android Build system Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development, Debugging and Performance Tools Development and Build Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia NDK / Middleware / HAL Operating System Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web Design and Development Website Hosting Wordpress Yocto Embedded Linux