B4R Question Native C: How to use Strings/Chars?

KMatle

Expert
Licensed User
I'm working on how to use AES with an ESP32. Everything is fine except how to use/return strings (byte arrays/chars). There are some threads but I don't get it.

Code:

B4X:
Private enc() As Byte ' In Globals

RunNative("InitAES",Null) ' Call
Inline C

B4X:
#if C
#include <mbedtls/aes.h>

char rstr[50];

void InitAES (B4R::Object* o) {
b4r_main::_enc = rstr;


}
#End if
Error:
B4X:
b4r_main.cpp:61: error: cannot convert 'char [50]' to 'B4R::Array*' in assignment
I simply need to return "rstr" to "enc"
 

thetahsk

Active Member
Licensed User
Try this

B4X:
b4r_main::_enc->data = rstr;
b4r_main::_enc->length = strlen(rstr);
 
Last edited:
Top