How to get the variable size in C

1 Answer

0 votes
#include <stdio.h>

int main(int argc, char **argv) 
{ 
    char c = 'a';
    int i = 100;
    float f = 91.7;
    double d = 3.012E23;
    
    printf("sizeof char   = %u\n", sizeof(c));
    printf("sizeof int    = %u\n", sizeof(i));
    printf("sizeof float  = %u\n", sizeof(f));
    printf("sizeof double = %u\n", sizeof(d));
    
    return(0);
}

/*
run:

sizeof char   = 1
sizeof int    = 4
sizeof float  = 4
sizeof double = 8

*/

 



answered Jun 15, 2015 by avibootz

Related questions

1 answer 129 views
1 answer 153 views
1 answer 181 views
2 answers 125 views
1 answer 101 views
101 views asked Nov 4, 2022 by avibootz
1 answer 189 views
1 answer 189 views
...