Warning: while trying to convert java byte[] to C unsigned char*

Viewed 1576

I am writing a JNI. In that, my Java program takes an Image byte array using ByteOutputStream() and then this array is used to call a function in C that converts byte array to unsigned char*. Here is the code:

JNIEXPORT void JNICALL Java_ImageConversion_covertBytes(JNIEnv *env, jobject obj, jbyteArray array) 
 {
    unsigned char* flag = (*env)->GetByteArrayElements(env, array, NULL);
    jsize size = (*env)->GetArrayLength(env, array);

    for(int i = 0; i < size; i++) {
    printf("%c", flag[i]);}
 }

In this I keep getting a warning when I compile:

warning: initializing 'unsigned char *' with an expression of type 'jbyte *' (aka 'signed char *') converts between pointers to integer types with different sign [-Wpointer-sign]

unsigned char* flag = (*env)->GetByteArrayElements(env, array, NULL);

How can I remove this warning? I want to print the all characters.

1 Answers
Related