Matlab coder generates string without the ending null terminator

4 visualizzazioni (ultimi 30 giorni)
Hi,
I want to pass a string to a c function doing this:
str = 'test_app';
coder.ceval('put_string', 'algorithm_name', coder.rref(str));
The generated code looks like this:
char cv0[14];
static const char cv1[8] = { 't', 'e', 's', 't', '_', 'a', 'p', 'p' };
static const char cv2[14] = { 'a', 'l', 'g', 'o', 'r', 'i', 't', 'h', 'm', '_',
'n', 'a', 'm', 'e' };
for (i0 = 0; i0 < 14; i0++) {
cv0[i0] = cv2[i0];
}
put_string(cv0, cv1);
How can I convince the coder to add the ending null terminator? I know this is a C/C++ convention but I'm trying to generate code for C here.
Thank you,
Bogdan

Risposte (0)

Categorie

Scopri di più su MATLAB Coder in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by