This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Printf question (newbie)

I want to print in a terminal the "%"character when I put

printf(" %c % ",var);

the % doesn't print

why??

Parents
  • If you are getting "c%" from

    printf("%c\%",'c');
    as compiled by your compiler, don't count on the same results from all compilers. By using "\%", you are in an "undefined" area of the C language. From H&S:

    If the character following the backslash is neither an octal digit, the letter x, nor one of the character escape codes (i.e., n t b r f v \ ' " a ?), the result is undefined.

Reply
  • If you are getting "c%" from

    printf("%c\%",'c');
    as compiled by your compiler, don't count on the same results from all compilers. By using "\%", you are in an "undefined" area of the C language. From H&S:

    If the character following the backslash is neither an octal digit, the letter x, nor one of the character escape codes (i.e., n t b r f v \ ' " a ?), the result is undefined.

Children
No data