Path: utzoo!mnetor!uunet!husc6!bbn!rochester!cornell!batcomputer!itsgw!steinmetz!davidsen From: davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) Newsgroups: comp.arch Subject: Re: Null-terminated C strings Message-ID: <8342@steinmetz.steinmetz.UUCP> Date: 4 Jan 88 14:31:44 GMT References: <261@ivory.SanDiego.NCR.COM| <164@sdeggo.UUCP> <174@quick.COM> <14116@think.UUCP> <2447@hall.cray.com> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric CRD, Schenectady, NY Lines: 34 In article <2447@hall.cray.com> blu@hall.UUCP (Brian Utterback) writes: | In article <14116@think.UUCP| barmar@sauron.think.com.UUCP (Barry Margolin) writes: | | stuff about null-terminated strings | | Amen to that. I just spent hours trying to find out what was wrong with | a rasterfile to laserprinter filter. It turned out that the problem is | that fprintf cannot output a null. This is just not so. Try fprintf("%c", '\000') and it works fine. fprintf works with standard C strings which are null terminated. Why complain because it doesn't do what you want? I suggest using putc if you want to force any character out. | At least the compiler should issue | a warning if it eats a null. I have never seem a compiler eat a null. For example: main() { static char xx[] = {"abc\000def"}; printf("%d bytes\n", sizeof xx); } returns a size of eight bytes. The null is not "eaten," it just doesn't work the way you want it to. | a warning if it eats a null. I mean, what is the use of being able to | specify a character in a string (i.e. \000) if the compiler won't really | use it? And it KNEW it, and didn't tell me. Sheesh. See above. I'm not against length defined strings, but I think that a posting like this indicates that the poster didn't understand the problem. Forgive me if you understood but failed to express yourself correctly. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs | seismo}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me