Reputation: 745
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
Upvotes: 2
Views: 2520
Reputation: 2386
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.
Upvotes: 2