By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

2D array init with memset

P: 1
#define VECTOR_LENGTH 255
#define MAX_RAD 15
#define MAX_ANGLE 15


double FR[MAX_RAD][MAX_ANGLE];
double FI[MAX_RAD][MAX_ANGLE];


condition a

memset(FR,0x00,sizeof(FR)); //initialization
memset(FI,0x00,sizeof(FI) );

condition b

memset(FR,0x00,sizeof(double) * VECTOR_LENGTH); //initialization
memset(FI,0x00,sizeof(double)* VECTOR_LENGTH );

Can anyone help, why “condition a” is corret, while “condition b” is wrong??

I found out that “condition b” also clear neigbouring variables declared after FR & FI.
May 30 '07 #1
Share this Question
Share on Google+
1 Reply


dumparun
P: 26
#define VECTOR_LENGTH 255
why is VECTOR_LENGTH 255 .....
15 * 15 = 225
you know the reason for your error, right....
May 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.