Converting a string to integer

Greg Perry <>
Tue Jun 2 01:32:40 CEST 2009

Ok I have another weird problem.  I have a file that contains a single
line that is a large number.  The file is read using read_file with the
second element of the tuple extracted:



Why don't this work?

io_lib:fread("~d", element(2,file:read_file("myfile.txt"))).

What would the easiest way be to extract a single line from a file and
convert it to an integer (for example the second element from a tuple
that read_file is assigned to)?

Thanks in advance


More information about the erlang-questions mailing list