| | |
program to find the size of primitive datatypes
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
The result of the sizeof operator will give you the size in bytes. The result type is size_t, but printf doesn't support printing size_t except in C99. You can get around that by casting the result to the largest unsigned integer type, unsigned long:
Rinse and repeat for every other type you want to display.
C Syntax (Toggle Plain Text)
printf("Size of int (in bytes): %lu\n", (unsigned long)sizeof(int));
Last edited by Radical Edward; Jun 12th, 2008 at 2:12 pm.
If at first you don't succeed, keep on sucking until you do succeed.
![]() |
Other Threads in the C Forum
- Previous Thread: plz help me -- pointer related
- Next Thread: Help in correcting this program
Views: 850 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C
#include * .net append array arrays bash binarysearch changingto char character cm command copyanyfile creafecopyofanytypeoffileinc createprocess() database directory dynamic execv feet fgets file floatingpointvalidation fork framework function functions getlogicaldrivestrin givemetehcodez global grade graphics gtkwinlinux histogram homework ide include initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list looping loopinsideloop. lowest matrix meter microsoft mqqueue mysql oddnumber odf openwebfoundation overwrite pause pdf pointer pointers posix power process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing segmentationfault single socket socketprogramming spoonfeeding standard strchr string student suggestions system test testing threads unix urboc user whythiscodecausesegmentationfault win32api windowsapi





