Faskist
Tuxhead
- Joined
- Apr 25, 2005
- Sythe Gold
- 0
- Messages
- 1,869
So, this morning, I wrote a simple program to sate my curiosity (Such is all hacking) about something I'd never bothered to find out -- just how big is the memory allocated to the datatypes we use everyday?
I know the code seriously needs refactoring, and it could be cleaned up so much, but I just wanted a quick solution.
The answer you'll get depends on platform, but in mine... int is as big as long!! The horror! The bloat!
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
i = sizeof(char);
printf( "A char is this big: |" );
while( i > 0)
{
printf( "-" );
--i;
}
printf( "|\n" );
i = sizeof(int);
printf( "An int is this big: |" );
while( i > 0)
{
printf( "-" );
--i;
}
printf( "|\n" );
i = sizeof(short);
printf( "A short is this big: |" );
while( i > 0)
{
printf( "-" );
--i;
}
printf( "|\n" );
i = sizeof(long);
printf( "A long is this big: |" );
while( i > 0)
{
printf( "-" );
--i;
}
printf( "|\n" );
return 0;
}
I know the code seriously needs refactoring, and it could be cleaned up so much, but I just wanted a quick solution.
The answer you'll get depends on platform, but in mine... int is as big as long!! The horror! The bloat!





































