Possible Duplicate:
What is faster/prefered memset or for loop to zero out an array of doubles
The following code uses memset to set all the bits to zero
int length = 5;
double *array = (double *) malloc(sizeof(double)*length);
memset(array,0,sizeof(double)*length);
for(int i=0;i<length;i++)
if(array[i]!=0.0)
fprintf(stderr,"not zero in: %d",i);
Can I assume that this will work on all platforms?
Does the double datatype always correspond to the ieee-754 standard?
thanks for your replies, and thanks for the ::fill template command. But my question was more in the sense of the double datatype.
Maybe I should have written my question for pure c. But thanks anyway.
EDIT: changed code and tag to c