The error still persists with the value "1". For "1" and "0" its not so......
Not getting why......
I used your way of
#define VECTOR_LEN 100
int main(int argc, char *argv[])
{
int a[VECTOR_LEN],i;
printf("Sizeof Array A is %d\n",sizeof a);
memset(a,0,sizeof(int)*VECTOR_LEN);
for(i=0;i<100;i++)
printf("%d\t",a[i]);
printf("\n\n");
memset(a,-1,sizeof(int)*VECTOR_LEN);
for(i=0;i<100;i++)
printf("%d\t",a[i]);
printf("\n\n");
memset(a,1,sizeof(int)*VECTOR_LEN);
for(i=0;i<100;i++)
printf("%d\t",a[i]);
printf("\n\n");
system("PAUSE");
return 0;
}
I am using Dev-C++ version 4.9.9.2
Regards,
Debasish
Fernando Henrique <[EMAIL PROTECTED]> wrote:
Hi..
Maybe I can help you...
Check if you are using properly the last parameter of memset. Maybe the
return sizeof(a) return would be 4 (int size), so, it can result a
unexpected result. A good implementation way is represent like this:
#define VECTOR_LEN 100
int a[VECTOR_LEN];
memset(a,-1,sizeof(int)* VECTOR_LEN);
int i = 10;
printf(Test the value of %d position -> %d,i,a[i]);
Run and check out the value. Feedback me. Bye,
Henrique, Fernando
----------------------------
"Keep walking"
_____
De: [email protected] [mailto:[EMAIL PROTECTED] Em nome de ranjan
kumar ojha
Enviada em: quarta-feira, 21 de março de 2007 04:42
Para: [email protected]
Assunto: [c-prog] about memset().....
Hi friends,
I got perplexed because of memset. look
int a[100];
memset(a,0,sizeof(a));
then it is filling 0 in array.
int a[100];
memset(a,-1,sizeof(a));
then it is filling -1 in array.
but
int a[100];
memset(a,1,sizeof(a));
then it is filling array by a big number. can any one explain this abnormal
behaviour of memset? plz also tell me internal implementation of memset.
if we fill 0 in an array using for loop & using memse also, which one will
be faster or both will take same time.
---------------------------------
Inbox full of unwanted email? Get leading protection and 1GB storage with
All New Yahoo! Mail.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
Karmennevaya Dhikaraste, Maaphaaleshu Kadaachanah
---------------------------------
Heres a new way to find what you're looking for - Yahoo! Answers
[Non-text portions of this message have been removed]