# Not accepting "%f" in ccall(:sscanf, args...)?

**URL:** <https://discourse.julialang.org/t/not-accepting-f-in-ccall-sscanf-args/51854>\
**Category:** General Usage\
**Tags:** question, ccall\
**Created:** [December 15, 2020, 7:38am UTC](https://discourse.julialang.org/t/not-accepting-f-in-ccall-sscanf-args/51854 "2020-12-15T07:38:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ibb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ibb/32/12083_2.png) [@Ibb](https://discourse.julialang.org/u/Ibb)\
**Post date:** [December 15, 2020, 7:38am UTC](https://discourse.julialang.org/t/not-accepting-f-in-ccall-sscanf-args/51854/1 "2020-12-15T07:38:29Z")

</div>

Test on Windows 10 19042.662, Julia version 1.5.3 (2020-11-09).  
Code below works.

```julia
u,v,w= Ref{Int32}(0),Ref{Int32}(0),Ref{Int32}(0)
ccall(:sscanf, Int, (Ptr{UInt8}, Ptr{UInt8}, Ref{Int32}, Ref{Int32}, Ref{Int32}), "1 2 3", "%d %d %d", u, v, w)

```

Code below doesn’t work.

```julia
u,v,x= Ref{Int32}(0),Ref{Int32}(0),Ref{Float32}(0)
ccall(:sscanf, Int, (Ptr{UInt8}, Ptr{UInt8}, Ref{Float32}, Ref{Int32}, Ref{Int32}), "1.0 2 3", "%f %d %d", x, u, v) # 0
ccall(:sscanf, Int, (Ptr{UInt8}, Ptr{UInt8}, Ref{Int32}, Ref{Float32}, Ref{Int32}), "1 2.0 3", "%d %f %d", u, x, v) # 1
ccall(:sscanf, Int, (Ptr{UInt8}, Ptr{UInt8}, Ref{Int32}, Ref{Int32}, Ref{Float32}), "1 2 3.0", "%d %d %f", u, v, x) # 2

```

Edit my post again. On Ubuntu 18.04.5 code above works! All returns “3” and “x” are correctly set.

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [December 15, 2020, 4:00pm UTC](https://discourse.julialang.org/t/not-accepting-f-in-ccall-sscanf-args/51854/2 "2020-12-15T16:00:52Z")

</div>

Try:

```julia
u,v,x= Ref{Int32}(0),Ref{Int32}(0),Ref{Float32}(0)

ccall(:sscanf, Cint, (Ptr{UInt8}, Ptr{UInt8}, Ptr{Cvoid}...), "1.0 2 3", "%f %d %d", x, u, v)
x[] == 1.0 && u[] == 2 && v[] == 3 && println("Test 1 works")
ccall(:sscanf, Cint, (Ptr{UInt8}, Ptr{UInt8}, Ptr{Cvoid}...), "1 2.0 3", "%d %f %d", u, x, v)
u[] == 1 && x[] == 2.0 && v[] == 3 && println("Test 2 works")
ccall(:sscanf, Cint, (Ptr{UInt8}, Ptr{UInt8}, Ptr{Cvoid}...), "1 2 3.0", "%d %d %f", u, v, x)
u[] == 1 && v[] == 2 && x[] == 3.0 && println("Test 3 works")

```

This seems to work on my linux box.

---

<div class="post-metadata">

**Author:** ![Ibb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ibb/32/12083_2.png) [@Ibb](https://discourse.julialang.org/u/Ibb)\
**Post date:** [December 16, 2020, 1:58am UTC](https://discourse.julialang.org/t/not-accepting-f-in-ccall-sscanf-args/51854/3 "2020-12-16T01:58:35Z")

</div>

Thx for your cleaner code, but my Julia on Windows 10 still can’t deal with “%f”, even using your code.
