How to get size of a different types of pointers in C

1 Answer

0 votes
#include <stdio.h>
 
int main(void)
{
    printf("Size of int pointer: %lu\n", (unsigned long)sizeof(int*));      
    printf("Size of char pointer: %lu\n", (unsigned long)sizeof(char*));   
    printf("Size of short pointer: %lu\n", (unsigned long)sizeof(short*)); 
    printf("Size of long pointer: %lu\n", (unsigned long)sizeof(long*)); 
    printf("Size of float pointer: %lu\n", (unsigned long)sizeof(float*)); 
    printf("Size of double pointer: %lu\n", (unsigned long)sizeof(double*)); 
 
    return 0;
}
 
   
/*
run:
     
Size of int pointer: 8
Size of char pointer: 8
Size of short pointer: 8
Size of long pointer: 8
Size of float pointer: 8
Size of double pointer: 8
 
*/

 



answered Jul 27, 2017 by avibootz

Related questions

1 answer 138 views
1 answer 148 views
1 answer 232 views
2 answers 162 views
1 answer 142 views
2 answers 226 views
...