dcsimg
How can i convert a jchar* to char* in cpp?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Haichao_Guan
Posted On:   Sunday, August 5, 2007 09:54 AM

Hello, i am a new to JNI and i have here a cpp programm like the following: first i have a jcharArray jcharArray cBuffer; cBuffer = env->GetCharArrayElements(cArray,NULL); then i have a function "SetSource", which expects as parameter a char* void SetSource(char* inBuffer) Now i want to use my jcharArray in the SetSource function, but it gets me the error, that a conversion from jcharArray to char* is not possible. Is there a way to get a jchar* from jcharArray and then convert from jchar* to char* ? Hope that somebody can help me. Greetings, Haichao    More>>

Hello, i am a new to JNI and i have here a cpp programm like the following:

first i have a jcharArray

			
jcharArray cBuffer;
cBuffer = env->GetCharArrayElements(cArray,NULL);


then i have a function "SetSource", which expects as parameter a char*

			
void SetSource(char* inBuffer)


Now i want to use my jcharArray in the SetSource function, but it gets me the error, that a conversion from jcharArray to char* is not possible.

Is there a way to get a jchar* from jcharArray and then convert from jchar* to char* ?

Hope that somebody can help me.

Greetings, Haichao    <<Less

Re: How can i convert a jchar* to char* in cpp?

Posted By:   Su_Ma  
Posted On:   Tuesday, August 21, 2007 05:06 PM

I assume this doesn't have to be a cpp problem, treat it as C problem, I would have used jstring but not jcharArry,you can get const char * from jstring with
(*env)->GetStringUTFChars(env,yourJstring,NULL);

then use a pointer cast to get a char *.

it works in my code, wish this helps.
About | Sitemap | Contact