Re: Bytes allocated by the code ??
- From: "Tom St Denis" <tomstdenis@xxxxxxxxx>
- Date: 28 Nov 2006 11:05:46 -0800
onkar 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);
Don't cast malloc (5th time today someone posted that...)
also
cdecl> explain int (*p)[]
declare p as pointer to array of int
p is a pointer to an array of MAXCOL ints. It isn't an array of
pointers [as you likely wanted].
Tom
.
- Follow-Ups:
- Re: Bytes allocated by the code ??
- From: Kenny McCormack
- Re: Bytes allocated by the code ??
- References:
- Bytes allocated by the code ??
- From: onkar
- Bytes allocated by the code ??
- Prev by Date: Re: Code fails with Segmentation Fault
- Next by Date: Re: Macros
- Previous by thread: Bytes allocated by the code ??
- Next by thread: Re: Bytes allocated by the code ??
- Index(es):
Relevant Pages
|