Error: an argument of type "int" is incompatible with a parameter of type "const void *"

in this part of my code when compiling the program. this error shows: "an argument of type" int "is incompatible with a parameter of type" const void * ". I declare a variable as follows:

int *dev_matrix, *dev_array, *dev_array_length; int array_length=1; cudaMalloc((void**)&dev_array_length, 1*sizeof(int)); cudaMemcpy(dev_array_length, array_length, 1*sizeof(int), cudaMemcpyHostToDevice); 
+4
source share
1 answer

The second argument to cudaMemcpy() . It is intended for a pointer ( const void* ), and you supply an int .

Did you mean to write:

 cudaMemcpy(dev_array_length, &array_length, 1*sizeof(int), cudaMemcpyHostToDevice); ^ 
+7
source

All Articles