Scanf Problem

In trying to read a line and convert it to variables my @scanf statement is giving unexpected (wrong) results. I am wondering if another set of eyes can pick out what I am doing wrong.

julia> using Scanf

julia> record4 = "  0.0000000E+00  0.0000000E+00  0.0000000E+00  0.0000000E+00  5.2706007E-02"
"  0.0000000E+00  0.0000000E+00  0.0000000E+00  0.0000000E+00  5.2706007E-02"

julia> n, uv1, uv2, uv3, uv4, uv5 = @scanf(record4, "%e15.7%e15.7%e15.7%e15.7%e15.7", Float64, Float64, Float64, Float64, Float64)
(1, 0.0, 0.0, 0.0, 0.0, 0.0)

julia>

This is your issue: you need to put the modifiers between the % and the e, but scanf doesn’t support restricting the decimal digits like that. The integer in %15e is the maximum total number of characters to consume. I’d just do "%e%e%e%e%e".

1 Like

This example should be added to the scanf documentation then?