I am trying to save in a char the symbol "\" and later print it but I can't.
Any good idea?
char direction = '\';
printf("%c", direction);
I am trying to save in a char the symbol "\" and later print it but I can't.
Any good idea?
char direction = '\';
printf("%c", direction);
You can directly print like this:
printf("\\");
for print any special character.
\\ - Backslash
\' - Single Quotation Mark
\" - Double Quotation Mark
\? - Question Mark
\n - New line
\r - Carriage Return
\t - Horizontal Tab
\b - Backspace
\f - Formfeed
\a - Bell (beep sound)
\v - Vertical Tab
ref : https://stackoverflow.com/a/11792217/5747242
C11 §6.4.4.4 Character constants and §5.2.2 Character display semantics also help.
You have to use '\\'. The backslash it's the escape character.