フィルターのクリア

Matlab coder generates string without the ending null terminator

1 回表示 (過去 30 日間)
Bogdan Iliuta
Bogdan Iliuta 2019 年 12 月 16 日
コメント済み: zohar kolberg 2020 年 3 月 16 日
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 件のコメント
Bogdan Iliuta
Bogdan Iliuta 2020 年 1 月 29 日
Such great community
zohar kolberg
zohar kolberg 2020 年 3 月 16 日
try str = ['test_app',0];
it works for me in matlab 2019b

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by