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]

Reply via email to