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:
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
Do you Yahoo!?
Meet the all-new My Yahoo! � Try it today!
To unsubscribe : [EMAIL PROTECTED]
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To reply to this message, go to:
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=4111
Please do not reply to this message via email. (more info)
- To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmers-Town/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
