#include <stdio.h>
//#include "gcc4_debug.h"
#define PS(str,x) printf("Memsize %5d bytes - sizeof "#str"\n", sizeof(x));
void test_size1(int a[100])
{
PS((Func-test_size1(char a[100]){printf sizeof(a);}), a);
}
int main()
{
int a1;
int *p1;
int a2[100];
int *p2[100];
struct A3
{
int i;
char p;
}a3;
union A4
{
int i;
char p;
}a4;
struct A3 *p3;
union A4 *p4;
char *p5 = "123456";
char p6[] = {'1','2','3','4','5','6'};
PS((int a1),a1);
PS((int a2[100]),a2);
PS((struct A3{int i;char p;}),a3);
PS((union A4{int i;char p;}),a4);
PS((int *p1),p1);
PS((int *p2[100]),p2);
PS((struct A3 *p3),p3);
PS((union A4 *p3),p4);
PS((char *p5 = "123456"),p5);
PS((char p6 = ['1','2','3','4','5','6']),p6);
test_size1(a2);
}
|
x86上面32bMemsize 4 bytes - sizeof (int a1)
Memsize 400 bytes - sizeof (int a2[100])
Memsize 8 bytes - sizeof (struct A3{int i;char p;})
Memsize 4 bytes - sizeof (union A4{int i;char p;})
Memsize 4 bytes - sizeof (int *p1)
Memsize 400 bytes - sizeof (int *p2[100])
Memsize 4 bytes - sizeof (struct A3 *p3)
Memsize 4 bytes - sizeof (union A4 *p3)
Memsize 4 bytes - sizeof (char *p5 = "123456")
Memsize 6 bytes - sizeof (char p6 = ['1','2','3','4','5','6'])
Memsize 4 bytes - sizeof (Func-test_size1(char a[100]){printf sizeof(a);})
阅读(2079) | 评论(0) | 转发(0) |