I am trying to use convert ASCII to Char in Android NDK but it gives me Fatal error for segement and my app force stops. Code:
value = "116";
char word = atoi(value);
return (*env)->NewStringUTF(env, word);
Error:
Fatal signal 11 (SIGSEGV) at 0x00000074
You need to provide NewStringUTF()
a c-string (i.e. an array of char
with an ending null):
value = "116";
char word[2];
word[0] = atoi(value); // first char converted as you want
word[1] = 0; // null termination (aka '\0')
return (*env)->NewStringUTF(env, word);
User contributions licensed under CC BY-SA 3.0