# How to use protected characters in a string (e.g. percent in printf)

**URL:** https://discourse.julialang.org/t/how-to-use-protected-characters-in-a-string-e-g-percent-in-printf/67239
**Category:** New to Julia
**Tags:** question, strings, printf
**Created:** [August 28, 2021, 6:18pm UTC](https://discourse.julialang.org/t/how-to-use-protected-characters-in-a-string-e-g-percent-in-printf/67239 "2021-08-28T18:18:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hdcpereira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hdcpereira/32/28705_2.png) [@hdcpereira](https://discourse.julialang.org/u/hdcpereira)
#### Post date: [August 28, 2021, 6:18pm UTC](https://discourse.julialang.org/t/how-to-use-protected-characters-in-a-string-e-g-percent-in-printf/67239/1 "2021-08-28T18:18:56Z")

</div>

Hello there.

How do I use these protected characters when writing a string?

```julia
@printf "this code has failed in %.2f" fail_percentage

```

I would like the output to be

```julia
this code has failed in 10.00%

```

but when I use the % symbol, it fails.

Also, I would like to properly print a float, with the proper amount of decimals. Is there a way to do so, without using printf?

thanks in advance.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [August 28, 2021, 6:25pm UTC](https://discourse.julialang.org/t/how-to-use-protected-characters-in-a-string-e-g-percent-in-printf/67239/2 "2021-08-28T18:25:41Z")

</div>

```julia
julia> @printf "this code has failed in %.2f%%" fail_percentage
this code has failed in 10.00%

```

see: [How to escape the % (percent) sign in C's printf - Stack Overflow](https://stackoverflow.com/questions/1860159/how-to-escape-the-percent-sign-in-cs-printf/1860164)
