i wanna write a code in julia, and i need input some data like c code(that explain below). how can i do this in julia?
in c code we wrote:
printf(" number = \n ");
scanf("%d", &N);
thanks in advance
i wanna write a code in julia, and i need input some data like c code(that explain below). how can i do this in julia?
in c code we wrote:
printf(" number = \n ");
scanf("%d", &N);
thanks in advance
You want readline
for getting input, and parse(T,s)
for parsing a string s
into type T
. Example
julia> s = readline()
1 # readline blocks until it sees \n, I typed the "1 enter" here
"1\n"
julia> parse(Int, chomp(s))
1
The above example uses Julia 0.5, readline
will remove the "\n" by default in 0.6 and later. And another user mentioned, with the REPL you rarely need to do this.