Re: Bytes allocated by the code ??
- From: roberson@xxxxxxxxxxxxxxxxxx (Walter Roberson)
- Date: Tue, 28 Nov 2006 20:16:20 +0000 (UTC)
In article <1164740226.991505.242720@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
onkar <onkar.n.m@xxxxxxxxx> wrote:
how many bytes will be allocted by following code -
#include<stdio.h>
#define MAXROW 3
#define MAXCOL 4
int main(int argc,char **argv){
int (*p)[MAXCOL];
p=(int (*)[MAXCOL])malloc(sizeof(*p)*MAXROW);
printf("%d\n",sizeof(*p));
return 0;
}
The number of bytes required to hold an int or a pointer differ between
platforms, so there isn't just one true correct numeric answer to your
question. Worse yet, different pointers can be different sizes (with
some restrictions) on the same platform -- all that is promised about
pointers to different types is that a void* pointer is the same size as
an unsigned char* pointer.
We could give you a symbolic answer, but not a numeric one.
--
All is vanity. -- Ecclesiastes
.
- References:
- Bytes allocated by the code ??
- From: onkar
- Bytes allocated by the code ??
- Prev by Date: Re: Question regarding fgets and new lines
- Next by Date: Re: Sharing static variables or function between source files.
- Previous by thread: Re: Bytes allocated by the code ??
- Next by thread: Re: Bytes allocated by the code ??
- Index(es):
Relevant Pages
|