print % in c

Richard Flamsholt S0rensen richard at iesd.auc.dk
Wed Feb 27 22:07:30 AEST 1991


>>>>> On 26 Feb 91 09:50:19 GMT, ok at goanna.cs.rmit.oz.au (Richard A. O'Keefe) said:
Richard> In article <1991Feb25.180600.5004 at ux1.cso.uiuc.edu>, gordon at osiris.cso.uiuc.edu (John Gordon) writes:
> 	To print special characters with printf(), precede the character
> with a \ character.  Example:

> 	printf("This a percent sign: \%\n");
> 	printf("This is a backslash: \\\n");

Richard> Did you *try* this?  Backslash is handled by one of the compiler
Richard> phases.  The string "This is a percent sign \%\n" turns into the
Richard> characters <T,h,i,s, ,i,s, ,a, ,p,e,r,c,e,n,t, ,s,i,g,n, ,%,NEWLINE>

  Did *you* try this? Backslash doesn't by any means "protect the next
char" - it handles a limited number of predefined escape sequences.

--
/Richard Flamsholt
richard at iesd.auc.dk



More information about the Comp.lang.c mailing list