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);
}
本文转自fengyuzaitu 51CTO博客,原文链接:http://blog.51cto.com/fengyuzaitu/1609505,如需转载请自行联系原作者