Clear Filters
Clear Filters

Matlab coder generates string without the ending null terminator

1 view (last 30 days)
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

Answers (0)

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!