I tried writing a hello world program on JOCL …
though the program runs fine I dont see the actual output. It shows sum unreadable characters…
I have attached the program
Note that there is a difference between a ‘char’ in C/OpenCL, and a ‘char’ in Java. In C/OpenCL a ‘char’ has exactly 1 byte. In Java, a ‘char’ has 2 bytes, because it can also store Unicode characters and all that… In Java, the variable type which has 1 byte is called ‘byte’.
Thus, to receive the desired output, you have to change your variable declarations to
(the last byte is ‘0’, which is required for C/OpenCL strings, but not for Java Strings)
bye
EDIT: By the way, you could probably leave out the additional ‘+1’ extra byte throughout the program, and finally print the result with
System.out.println(new String(dst));