Hi Gururaj
    
     Regarding your first program:
    
      int (*p)[MAXCOL] - declares that : p is a pointer to an array of size /dimension MAXCOL which is (array) integer type.
 
     now u assingned memory to p.
     so sizeof(p) always return returns 2 cause it is a pointer that points to an integer type;
 
   now sizeof(*p) returns 8 cause array actually holds 4 integers means 8 bit and sizeof() operator always returns in bit.
 
cheers
 
Tushar 

Gururaj K J <[EMAIL PROTECTED]> wrote:


 
Hi folks,
      Can anyone give the explanations for the following:

1) #include"alloc.h"
    #define MAXROW 3
    #define MAXCOL 4
    main()
    {
    int (*p)[MAXCOL];
    p=(int(*)[MAXCOL]) malloc(MAXROW *sizeof(*p));
    printf("%d%d",sizeof(p),sizeof(*p));
      }

Ans: 2  8

2)#include"alloc.h"
#define MAXROW 3
#define MAXCOL 4
main()
{
    int (*p)[MAXCOL][MACROW];
    p=(int(*)[MAXROW][MAXCOL])malloc(sizeof(*p));
}

Ans: 14 bytes





To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=298184.5639630.6699735.3001176/D=groups/S=:HM/A=2434971/rand=537347734


Do you Yahoo!?
Meet the all-new My Yahoo! � Try it today!

To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=294855.5468653.6549235.3001176/D=groups/S=:HM/A=2376776/rand=805412965


Yahoo! Groups Links

Reply via email to