Admin Production ni-theme
Current Publication

Determining Buffer Size for String Values

LabWindows/CVI

Determining Buffer Size for String Values

LabWindows/CVI libraries include functions and attributes that return string values. To determine the buffer size to allocate for the string value, you can use one of the buffer length functions and attributes provided by the LabWindows/CVI libraries.

For example, to get the buffer size for the label of a control, call GetCtrlAttribute with the ATTR_LABEL_TEXT_LENGTH attribute, as shown in the following:

int labelLen;
int panelHandle;
char *ptr;
char *labelText;

GetCtrlAttribute (panelHandle, PANEL_TEXTMSG, ATTR_LABEL_TEXT_LENGTH, &labelLen);
ptr = malloc (labelLen + 1);
labelText = ptr;
GetCtrlAttribute (panelHandle, PANEL_TEXTMSG, ATTR_LABEL_TEXT, labelText);