string conversion, format functions

Matthias Lang matthias@REDACTED
Wed Apr 23 23:39:28 CEST 2003



 > > B = 3.
 > > 
 > > I want to form a string "0003".  
 > >   ** Can io:format generate such a printout ? 

Try

  9> B = 3.
  3
  10> io:fwrite("~4.4.0w\n", [B]).
  0003
  ok

integers are formatted using the 'term' format (~w), there's no need
for an explicit 'integer' format.

You can use io_lib if you want to generate strings rather than
printing to output.

Matthias



More information about the erlang-questions mailing list