Chapter 2 Formatting and I/O Library
© National Instruments Corporation 2-51 LabWindows/CVI Standard Libraries
Fmt (buf, "%s<%i[w6p0]", a); /* result: "001234" */
a = 1234;
Fmt (buf, "%s<%i[w2]", a); /* result: "*4" */
Remarks
The results shown are the contents of buf after each call to Fmt. The last call demonstrates
what occurs when the width specified by the w modifier is too small.
Long Integer to String
char buf[20];
long a;
a = 123456;
Fmt (buf, "%s<%i[b4]", a); /* result: "123456" */
a = 123456;
Fmt (buf, "%s<%x[b4]", a); /* result: "1e240" */
a = 123456;
Fmt (buf, "%s<%o[b4]", a); /* result: "361100" */
a = -1;
Fmt (buf, "%s<%i[b4]", a); /* result: "-1" */
a = -1;
Fmt (buf, "%s<%i[b4u]", a); /* result: "4294967295" */
a = 123456;
Fmt (buf, "%s<%i[b4w8]", a); /* result: " 123456" */
a = 123456;
Fmt (buf, "%s<%i[b4w8p0]", a); /* result: "00123456" */
a = 123456;
Fmt (buf, "%s<%i[b4w4]", a); /* result: "*456" */
Remarks
The results shown are the contents of buf after each call to Fmt. The last call demonstrates
what occurs when the width specified by the w modifier is too small.
Real to String in Floating-Point Notation
char buf[30]
double x;
x = 12.3456789;
Fmt (buf, "%s<%f", x); /* result: "12.345679" */
x = 12.3456789;
Fmt (buf, "%s<%f[p2]", x); /* result: "12.35" */
x = 12.3456789;
Fmt (buf, "%s<%f[p10]", x); /* result: "12.3456789000" */
x = 12.345;
Fmt (buf, "%s<%f", x); /* result: "12.345" */
x = 12.345;