The Khronos Group - a non-profit industry consortium to develop, publish and promote open standard, royalty-free media authoring and acceleration standards for desktop and handheld devices, combined with conformance qualification programs for platform and device interoperability.

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

The result is that all elements of c[] are 0 (not the same with the a[])
However, if I define the array in the host program as

int a[81]; //not using "new"

It all worked. Since I may need to build a really big array in the real program, I think I'll have to use the first method to avoid the stack overflow problem.
So, if someone can tell me where I'm doing wrong, or is it impossible to pass an array defined in that way to a kernel program?

This issue is that you are incorrectly using 'sizeof(a)' to determine the size of your array. The sizeof operator computes the size of the datatype you give it, not the size of the array you allocated. In your first case (with malloc), the data type is an int*, and so sizeof(a) will be either 4 or 8 bytes, depending on the architecture. In the second case, the data type is int[81], and sizeof(a) will be 81*sizeof(int) bytes, which is why it works.