JNI - (Java) Pass a String to C++/Return a String from C++

I am trying to "Pass a string to C++" using JNI<~~~I am successful. If I "Return a string back to Java"<~~I am successful also. When I "pass a string" to a C++ function(within C++), I can't "return a string". To make it more understandable, using Java, I need to pass a String to C++. In C++, I need to pass the String that came from Java to a C++ function. The C++ function needs to return a String. I believe the problem is the C++ function is unable to return the String. Someone please HELP!!! Below is my C++ code:

#include <string.h>

#include <stdio.h>

#include <iostream.h>

#include <jni.h>

#include "PassReturnString.h"

char returnString(char*);

JNIEXPORT jstring JNICALL Java_PassReturnString_showString

(JNIEnv *env, jobject obj, jstring jstr) {

static char copyStr[32];

const char* str = env->GetStringUTFChars(jstr, 0);

strcpy(copyStr, str);

env->ReleaseStringUTFChars(jstr, str);

const char *ret = (char*)returnString(copyStr);

return env->NewStringUTF(ret);

}

char returnString(char* c) {

char *back;

if(*c == '1') {

back = "Hello";

printf("%s", back);

return *back;

}

else if(*c == '2') {

back = "World";

printf("%s", back);

return *back;

}

else if(*c == '3') {

back = "!!!";

printf("%s", back);

return *back;

}

else {

back = "Error";

printf("%s", back);

return *back;

}

}

[1576 byte] By [sinsai] at [2007-9-26 5:19:29]
# 1
i resolved the problem...does anyone know how to remove/unassign the DUKE pts?
sinsai at 2007-6-29 19:24:26 > top of Java-index,Java HotSpot Virtual Machine,Specifications...