Matlab coder generates string without the ending null terminator
4 次查看(过去 30 天)
显示 更早的评论
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
2 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!