How to read integer in Erlang?
- by Jace Jung
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.