R
rahul8143
hello,
Why am i getting different sizeof values for struct mm and mm1?
Also why name array of length upto 4 gives struct sizes as 8 and above
that changes to 12?
#include <stdio.h>
main()
{
struct mm
{
char *name;
int no;
};
struct mm1
{
char *name[0];
int no;
};
struct mm2
{
char name[4];
int no;
};
struct mm3
{
char name[5];
int no;
};
printf("size of mm is =%d\n",sizeof(struct mm));
printf("size of mm1 is =%d\n",sizeof(struct mm1));
printf("size of mm2 is =%d\n",sizeof(struct mm2));
printf("size of mm3 is =%d\n",sizeof(struct mm3));
}
/*output
size of mm is =8
size of mm1 is =4
size of mm2 is =8
size of mm3 is =12 */
Why am i getting different sizeof values for struct mm and mm1?
Also why name array of length upto 4 gives struct sizes as 8 and above
that changes to 12?
#include <stdio.h>
main()
{
struct mm
{
char *name;
int no;
};
struct mm1
{
char *name[0];
int no;
};
struct mm2
{
char name[4];
int no;
};
struct mm3
{
char name[5];
int no;
};
printf("size of mm is =%d\n",sizeof(struct mm));
printf("size of mm1 is =%d\n",sizeof(struct mm1));
printf("size of mm2 is =%d\n",sizeof(struct mm2));
printf("size of mm3 is =%d\n",sizeof(struct mm3));
}
/*output
size of mm is =8
size of mm1 is =4
size of mm2 is =8
size of mm3 is =12 */