I have a program,which reads a String from the user.
char buf[128];
const jbyte *jnistr;
jsize strsize;
jnistr = (*env)->GetStringUTFChars(env,prompt,NULL);
if(jnistr==NULL){
return;
}
strsize = (*env)->GetStringLength(env,prompt);
testBuffer(*jnistr,strsize);
After converion, it is in the varibale jnistr ,which is a const jbyte.
My confusion starts here:
How can I pass the const jbyte to a C function, so that the whole
string is accessible.
When I try to return the jnistr, and accept it as a char parameter in
the C function testBuffer(), I can only read the first letter of the
string and nothing beyond that.
Thank You,
Ann
Gordon Beaton - 18 Nov 2004 07:39 GMT
> const jbyte *jnistr;
> testBuffer(*jnistr,strsize);
> When I try to return the jnistr, and accept it as a char parameter
> in the C function testBuffer(), I can only read the first letter of
> the string and nothing beyond that.
That's because you've passed the wrong type to testBuffer(). If jnistr
is declared as jbyte*, then *jnistr is a single jbyte, not an array of
them.
Pass it like this instead:
testBuffer(jnistr, strsize);
I suspect that testBuffer() is declared incorrectly as well, or that
you've ignored warnings from your compiler.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e