Created
April 7, 2019 08:39
-
-
Save moiz-frost/7bbc3164dcab029162d8d8f1ef751a32 to your computer and use it in GitHub Desktop.
A small program to print out the size of primitive types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main() { | |
int i = 123; | |
float f = 98.6; | |
double d = 6.022E23; | |
char c = 'c'; | |
int* iPtr = &i; | |
float* fPtr = &f; | |
double* dPtr = &d; | |
char* cPtr = &c; | |
void* vPtr = &c; | |
printf("int\t%lu\n", sizeof(i)); | |
printf("integer pointer\t%lu\n", sizeof(iPtr)); | |
printf("float\t%lu\n", sizeof(f)); | |
printf("float pointer\t%lu\n", sizeof(fPtr)); | |
printf("double\t%lu\n", sizeof(d)); | |
printf("double pointer\t%lu\n", sizeof(dPtr)); | |
printf("char\t%lu\n", sizeof(c)); | |
printf("void pointer\t%lu\n", sizeof(cPtr)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment