C Data Type Sizes#
| MSOFT 32 | MSOFT 64 | MSOFT 64 Cygwin | Linux 32 | Linux 64 | Max OS/X<br>Intel/M1 | |
|---|---|---|---|---|---|---|
| char | 1 | 1 | 1 | 1 | 1 | 1 |
| short | 2 | 2 | 2 | 2 | 2 | 2 |
| int | 4 | 4 | 4 | 4 | 4 | 4 |
| long | 4 | 4 | 8 | 4 | 8 | 8 |
| long long | 8 | 8 | 8 | 8 | 8 | 8 |
| float | 4 | 4 | 4 | 4 | 4 | 4 |
| double | 8 | 8 | 8 | 8 | 8 | 8 |
| char* | 4 | 8 | 8 | 4 | 8 | 8 |
Program Used#
#include <stdio.h>
#define PS(x) printf("sizeof(" #x ") = %d\n", (int)sizeof(x))
int main()
{
PS(char);
PS(short);
PS(int);
PS(long);
PS(long long);
PS(float);
PS(double);
PS(char *);
return 0;
}
int to pointer code#
/* an int that is the same size as a pointer */ #include <stdint.h> intptr_t myInt; void *ptr = (void *) 123; myInt = (intptr_t) ptr;
Add new attachment
Only authorized users are allowed to upload new attachments.
«
This page (revision-6) was last changed on 05-Nov-2023 16:26 by BlakeMcBride
JSPWiki v2.10.4