User`s guide
46 Agilent VISA User’s Guide
3 Programming with VISA
Sample: Using Field Width Modifier
The following sample pads numb to six characters and
sends it to the session specified by vi:
int numb = 61;
viPrintf(vi, "%6d\n", numb);
Inserts four spaces, for a total of 6 characters: 61
.Precision Precision is an optional integer preceded by a
period. This modifier is only used with the viPrintf and
viQueryf (writeFmt) functions. The meaning of this
argument is dependent on the conversion character used.
You can use an asterisk (*) in place of the integer to
indicate the integer is taken from the next argument.
Sample: Using the Precision Modifier
This sample converts numb so that there are only two
digits to the right of the decimal point and sends it to the
session specified by vi:
float numb = 26.9345;
viPrintf(vi, "%.2f\n", numb);
Sends: 26.93
Table 11 Descriptions of Format Codes
Format Code Description
d Indicates the minimum number of digits to appear is specified
for the @1, @H, @Q, and @B flags, and the i, o, u, x, and X format
codes.
f Indicates the maximum number of digits after the decimal point
is specified.
s Indicates the maximum number of characters for the string is
specified.
g Indicates the maximum significant digits are specified.