C代码:
JNIEXPORT jstring JNICALL Java_Sample1_stringMethod(JNIEnv *env, jobject obj, jstring string)
{
const char *str = (*env)->GetStringUTFChars(env, string, 0);
char cap[128];
strcpy(cap, str);
(*env)->ReleaseStringUTFChars(env, string, str);
int i=0;
for(i=0;i
*(cap+i)=(char)toupper(*(cap+i));
return (*env)->NewStringUTF(env, cap);
}
C++代码:
JNIEXPORT jstring JNICALL Java_Sample1_stringMethod(JNIEnv *env, jobject obj, jstring string)
{
const char *str = (env)->GetStringUTFChars(string, 0);
char cap[128];
strcpy(cap, str);
(env)->ReleaseStringUTFChars(string, str);
int i=0;
for(i=0;i
*(cap+i)=(char)toupper(*(cap+i));
return (env)->NewStringUTF(cap);
}
转载于:https://blog.51cto.com/fengyuzaitu/2309287