logo       

Re: string conversion, format functions: msg#00338

lang.erlang.general

Subject: Re: string conversion, format functions



> > 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



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise