I am new to C/C++, so I don't know how to properly convert a byte array in Java to a char array in JNI.
For example, I have an inputString containing "Hello world!", I use this to get the byte array:
byte[] data = inputString.getBytes();
Then in the JNI layer, I use:
jbyte *array = (*env)->GetByteArrayElements(env, data, &isCopy);
argv[1] = (char *)array;
Then when I print the argv[1], it is "Hello world!ZE".
Why is there extra characters "ZE" here?
Would anyone explain this, and provide me the right solution to convert byte[] to char* pointer? I need the char* pointer because the interface I am given is char* pointer for me.