How to read integer in Erlang?
Posted
by Jace Jung
on Stack Overflow
See other posts from Stack Overflow
or by Jace Jung
Published on 2009-03-27T01:58:57Z
Indexed on
2010/04/30
12:07 UTC
Read the original article
Hit count: 373
I'm trying to read user input of integer. (like cin >> nInput; in C++)
I found io:fread bif from http://www.erlang.org/doc/man/io.html, so I write code like this.
{ok, X} = io:fread("input : ", "~d"),
io:format("~p~n", [X]).
but when I input 10, the erlang terminal keep giving me "\n" not 10. I assume fread automatically read 10 and conert this into string. How can I read integer value directly? Is there any way to do this? Thank you for reading this.
© Stack Overflow or respective owner