diff --git a/examples/common/scpi-def.c b/examples/common/scpi-def.c index e1089ccf..4e690b86 100644 --- a/examples/common/scpi-def.c +++ b/examples/common/scpi-def.c @@ -170,8 +170,8 @@ static scpi_result_t TEST_Text(scpi_t * context) { char buffer[100]; size_t copy_len; - buffer[0] = 0; - SCPI_ParamCopyText(context, buffer, 100, ©_len, FALSE); + SCPI_ParamCopyText(context, buffer, sizeof(buffer), ©_len, FALSE); + buffer[copy_len] = '\0'; fprintf(stderr, "TEXT: ***%s***\r\n", buffer); diff --git a/examples/common/scpi-def.cpp b/examples/common/scpi-def.cpp index c53fa4f8..d3b737c9 100644 --- a/examples/common/scpi-def.cpp +++ b/examples/common/scpi-def.cpp @@ -167,8 +167,8 @@ scpi_result_t TEST_Text(scpi_t * context) { char buffer[100]; size_t copy_len; - buffer[0] = 0; - SCPI_ParamCopyText(context, buffer, 100, ©_len, false); + SCPI_ParamCopyText(context, buffer, sizeof(buffer), ©_len, false); + buffer[copy_len] = '\0'; fprintf(stderr, "TEXT: ***%s***\r\n", buffer);