/* big12.c check for 64 bit long etc int still 32 bit */ /* gcc -o big big.c -m64 needed on older OS */ /* ./big output shows sizes */ #include #include #include static char * b; /* try malloc at 10GB */ static long fact(long n) /* n! */ { if(n<=1l) return 1l; return n*fact(n-1l); } int main(int argc, char *argv[]) { int i, int1; long n, long1; long long llong1; float fl1; double d1; size_t sz1; int * p1; printf("big12.c compiled gcc -o big12 big12.c (64 bit long)\n"); printf("-m64 needed on some older OS \n"); printf("sizeof(sizeof(int))=%ld, sizeof needs pct ld \n", sizeof(sizeof(int))); printf("sizeof(int)=%ld, sizeof(int1)=%ld \n", sizeof(int), sizeof(int1)); printf("sizeof(long)=%ld, sizeof(long1)=%ld \n", sizeof(long), sizeof(long1)); printf("sizeof(long long)=%ld, sizeof(llong1)=%ld \n", sizeof(long long), sizeof(llong1)); printf("sizeof(float)=%ld, sizeof(fl1)=%ld \n", sizeof(float), sizeof(fl1)); printf("sizeof(double)=%ld, sizeof(d1)=%ld \n", sizeof(double), sizeof(d1)); printf("sizeof(size_t)=%ld, sizeof(sz1)=%ld \n", sizeof(size_t), sizeof(sz1)); printf("sizeof(int *)=%ld, sizeof(p1)=%ld \n", sizeof(int *), sizeof(p1)); printf("n factorial with n of type long \n"); for(n=0; n<25; n++) { printf("%ld ! = %ld \n", n, fact(n)); } printf("trying to malloc 10GB \n"); b = (char *)malloc(10000000000l); if(b==NULL) printf("malloc failed b==NULL \n"); else { printf("malloc returned \n"); for(n=0; n<10000000000l; n+=10000l) b[n]='a'; printf("stored 10GB of 'a' \n"); } return 0; } /* end big12.c */