From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Advantage of Fmt over sprintf

Solved!
Go to solution

Are there advantages of using fmt over sprintf in CVI code? On the surface, they appear to be very similar down to the interpretation of the format string. I understand that the sprintf format string allows for more options, but those aren't always necessary in my projects.

 

0 Kudos
Message 1 of 5
(4,881 Views)
Solution
Accepted by topic author Les__Bartel

NI's recommendation is to use printf/scanf instead of Fmt/Scan, see the discussion here

Message 2 of 5
(4,878 Views)
I use Fmt and Scan mostly for the t (terminate) and d (discard) flags. I do not know their equivalent for sprintf. Fmt is much better documented than sprintf.
Does anybody have a full feature list of sprintf?
S. Eren BALCI
IMESTEK
0 Kudos
Message 3 of 5
(4,863 Views)

This Wikipedia page documents it. See also it's many references.

 

http://en.wikipedia.org/wiki/Printf_format_string

 

0 Kudos
Message 4 of 5
(4,858 Views)

As a side comment over Wolfgang note, look at the last comment by LuisG in the linked Idea exchange thread: Fmt/Scan are not to be considered obsolete or deprecated. It seems true, nevertheless, that no further addition is to be expected on these functions.

I am still using Scan sometimes in my programs as it appears to have a few more options than sscanf that are useful in some particular situations.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 5
(4,840 Views)