User Tools

Site Tools


sizeof

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sizeof [2013/06/17 12:01]
mihael
sizeof [2013/06/20 07:00]
Line 1: Line 1:
-====== Size Of ====== 
-Prints the size of variables on the standard out. 
  
-<​code>​ 
-#include <​stdio.h>​ 
-#define PTRINT_SHORT 
-#ifdef PTRINT_SHORT 
-    typedef short ptrint; 
-#endif 
-#ifdef PTRINT_INT 
-    typedef int ptrint; 
-#endif 
-#ifdef PTRINT_LONG 
-    typedef long ptrint; 
-#endif 
-#ifdef PTRINT_LONGLONG 
-    typedef long long ptrint; 
-#endif 
-  
-int main(void) { 
-    if (sizeof(ptrint) != sizeof(void*)) { 
-        printf ("​ERROR:​ ptrint doesn'​t match void* for this platform.\n"​);​ 
-        printf (" ​  ​sizeof(void* ​   ) = %d\n", sizeof(void*));​ 
-        printf (" ​  ​sizeof(ptrint ​  ) = %d\n", sizeof(ptrint));​ 
-        printf (" ​  ​=================\n"​);​ 
-        printf (" ​  ​sizeof(void* ​   ) = %d\n", sizeof(void*));​ 
-        printf (" ​  ​sizeof(short ​   ) = %d\n", sizeof(short));​ 
-        printf (" ​  ​sizeof(int ​     ) = %d\n", sizeof(int));​ 
-        printf (" ​  ​sizeof(long ​    ) = %d\n", sizeof(long));​ 
-        printf (" ​  ​sizeof(long long) = %d\n", sizeof(long long)); 
-        printf (" ​  ​sizeof(uns. int ) = %d\n", sizeof(unsigned int)); 
-        printf (" ​  ​sizeof(sig. int ) = %d\n", sizeof(int));​ 
-        printf (" ​  ​sizeof(uns. long) = %d\n", sizeof(unsigned long)); 
-        printf (" ​  ​sizeof(sig. long) = %d\n", sizeof(long));​ 
-        return 1; 
-    } 
-  
-    /* rest of your code here */ 
-  
-    return 0; 
-} 
-</​code>​ 
- 
-{{tag>​devel c ibm}} 
sizeof.txt ยท Last modified: 2013/06/20 07:00 (external edit)