Memset problem


I write that code just for check if memset is working properly

float * distanceTransformDevice;



float * distanceTransform=new float[SCREEN_RES];


//Print distanceTransform to File

But the file do not contain '2.'s (which should). Does anyone knows why?

Thank you very much.

This will happen for you in regular c++ as well… nothing to do with CUDA.

You can only use memset to set an array items like this for BYTE/char elements (element size 1)…


I didn’t know that. I thought that everything should work correctly since I set right the number of bytes. But you are right. It just works for char/Byte arrays.

Thank you very much.