print % in c

Sean Eric Fagan sef at kithrup.COM
Thu Feb 28 19:16:54 AEST 1991


In article <1991Feb27.020629.24624 at dvorak.amd.com> tim at amd.com (Tim Olson) writes:
>The real answer is that '\' is a special escape character for
>character constants and strings in C, and it is processed at
>compile/assemble time.  It can be used to represent frequently used
>values (e.g. \t = tab, \r = return, \n = newline, \\ = \), as well any
>character by following the backslash with an octal constant.

Heh.  Moderately amusing story:  a friend of mine had worked extensively on
a Small-C compiler, to the point where it was not quite small-C anymore.
Anyway, the compiler treated "\%" as "\%", and his version of printf treated
that as an escape for '%' (i.e., equivalent to '%%').

He didn't believe me when I told him he was wrong... 8-)

-- 
Sean Eric Fagan  | "I made the universe, but please don't blame me for it;
sef at kithrup.COM  |  I had a bellyache at the time."
-----------------+           -- The Turtle (Stephen King, _It_)
Any opinions expressed are my own, and generally unpopular with others.



More information about the Comp.lang.c mailing list