Formatting and I/O Library Chapter 2
LabWindows/CVI Standard Libraries 2-56 © National Instruments Corporation
Concatenating Two Strings
char buf[30];
int wave_type, signal_output;
char *wave_str, *signal_str;
int nbytes;
wave_type = 1;
signal_output = 0;
switch (wave_type) {
case 0:
wave_str = "SINE;"
break;
case 1:
wave_str = "SQUARE;"
break;
case 2:
wave_str = "TRIANGLE;"
break;
}
switch (signal_output) {
case 0:
signal_str = "OUTPUT OFF;"
break;
case 1:
signal_str = "OUTPUT ON;"
break;
}
Fmt (buf, "%s<%s%s", wave_str, signal_str);
nbytes = NumFmtdBytes ();
RemarksThe two switch constructs assign constant strings to the string variables wave_str andsignal_str. The Fmt call concatenates the contents of wave_str and signal_str intobuf. After the call, buf contains "SQUARE;OUTPUT OFF;". NumFmtdBytes returnsthe number of bytes in the concatenated string.Appending to a String
char buf[30];
int wave_type, signal_output;
int nbytes;
switch (wave_type) {
case 0:
Fmt (buf, "%s<SINE;");
break;
case 1:
Fmt (buf, "%s<SQUARE;");
break;