Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!mintaka!olivea!uunet!comp.vuw.ac.nz!actrix!Bruce.Hoult From: Bruce.Hoult@bbs.actrix.gen.nz Newsgroups: comp.sys.mac.programmer Subject: Re: New Think C user Message-ID: <1991Feb10.093129.15589@actrix.gen.nz> Date: 10 Feb 91 09:31:29 GMT References: <21005@sri-unix.SRI.COM> Sender: Bruce.Hoult@actrix.gen.nz (Bruce Hoult) Organization: Actrix Information Exchange, Wellington, New Zealand Lines: 23 Comment-To: mxmora@sri-unix.sri.com Matt Mora writes: >Why do you have to use a double percent sign in a string literal to have >it print a percent sign when all logic would indicate that a backslash >percent sign should work? Unfortunately, that's the wrong logic :-) >So you would think that since the percent sign is the mask in a string >literal that if a backslash was before it, the compiler would do the >right thing. It does. :-) When you use \% the compiler does exactly the right thing -- it puts a % into the compiled format string, just the same as typing a % by itself does. The problem is that the format string isn't interpreted by the compiler, but by the runtime library, which sees only the %, not the \%. -- Bruce.Hoult@bbs.actrix.gen.nz Twisted pair: +64 4 772 116 BIX: brucehoult Last Resort: PO Box 4145 Wellington, NZ "And they shall beat their swords into plowshares, for if you hit a man with a plowshare, he's going to know he's been hit."