Matlab coder generates string without the ending null terminator

4 Ansichten (letzte 30 Tage)
Bogdan Iliuta
Bogdan Iliuta am 16 Dez. 2019
Kommentiert: zohar kolberg am 16 Mär. 2020
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

Antworten (0)

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by