2

This is my first text based game and I have almost no experience in coding. I've recently run into a problem where I try to echo a "%" but it won't appear in the command processor. Here are some lines of the code:

echo 10. If an icosahedron die has 20 faces, what is the probability of rolling a number with 1 in its digits?
echo A) 40%
echo B) 70%
echo C) 55%
echo D) 95%

But when I run it on the processor, the "%" does not display. Next I've tried this:

echo A) 40^%^

But it does not work. So I searched and tried this:

echo A) 40"%"

But it does not work as well. Do you know anything that can help?

  • 2
    To specify a literal percent sign as a string, double it. Also, depending on whether your `echo` statements exist within a parenthetical code block, you might need to caret escape the `)` symbol. `echo A^) 40%%` – rojo May 25 '17 at 13:50
  • Thanks guys. It actually helped. I'll keep this in mind. – Calvin Mathay May 25 '17 at 13:57
  • 4
    Possible duplicate of [Batch: Auto escape special characters](https://stackoverflow.com/questions/42801769/batch-auto-escape-special-characters) or of [How does the Windows Command Interpreter (CMD.EXE) parse scripts?](https://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts) – Mofi May 25 '17 at 14:53
  • 1
    Possible duplicate of [How does the Windows Command Interpreter (CMD.EXE) parse scripts?](https://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts) –  Jan 10 '18 at 09:49

0 Answers0