I'd like to know if all formatting rules of printf functions currently work (or are implemented) in F# ?
For instance, if I want to align arguments on 9 characters (padding with spaces or 0), I would use:
printfn "%9A %9A" arg1 arg2 //don't seem to work
Thanks!
The key difference between them is that printf() prints the formatted String into console much like System. out. println() but the format() method returns a formatted string, which you can store or use the way you want.
The printf prototype is defined in the <cstdio> header file. When you use the printf() function, it prints the string pointed out by the format to the standard output stdout. The format can also contain some specifiers that start with a % and replace values of variables with the printf() function.
The %d specifies that the single variable is a decimal integer. The %n is a platform-independent newline character. The output is: The value of i is: 461012. The printf and format methods are overloaded.
"printf" is the name of one of the main C output functions, and stands for "print formatted". printf format strings are complementary to scanf format strings, which provide formatted input (lexing aka. parsing).
Do check out the docs
http://msdn.microsoft.com/en-us/library/ee370560(v=VS.100).aspx
(and possibly also these
http://en.wikibooks.org/wiki/F_Sharp_Programming/Input_and_Output
http://blogs.msdn.com/dsyme/archive/2010/01/08/some-tips-and-tricks-for-formatting-data-in-f-interactive-and-a-in-sprintf-printf-fprintf.aspx
)
though I am unclear about the fine points of the spec and implementation, especially regarding the %A specifier, which does various magical things. I'll see what other info I can dig up right now...
Read the documentation:
http://msdn.microsoft.com/en-us/library/ee370560.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With