#include<stdio.h>
#include<conio.h>
#include<string.h>
struct 
{
    int num1,num2;
    char s1;
    int *ptr;
    int abc[5];
}a[2];

void main()

 {
     int start, last;
     start=&a[1].num1;//error
     last=&a[0].num1;//error
     printf("\nsize of structure :%d bytes",start-last);
     getch();
     }


    getch();
}

Recommended Answers

All 3 Replies

please correct error in 16 and 17 lines

remove the & address symbol from both those lines

Seeing as start and last are both int, you just need to cast &a[1].num1 and &a[0].num1 as type int.
start = (int) &a[1].num1;
Or quite simply you could use:
printf("\nsize of structure :%d bytes", sizeof(a[0]) );

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.