Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdahl!oliveb!tymix!antares!jms From: jms@antares.UUCP (Joe Smith) Newsgroups: comp.sys.amiga Subject: Re: Struggling through the "C" Summary: =! is not != Message-ID: <433@antares.UUCP> Date: 2 Apr 89 03:03:15 GMT References: <12000@louie.udel.EDU> Reply-To: jms@antares.UUCP (Joe Smith) Organization: Tymnet QSATS, San Jose CA Lines: 25 I have seen 2 follow ups to this question, neither of which addresses the real problem. In article <12000@louie.udel.EDU> LIZAK98%SNYBUFVA.BITNET@cornellc.cit.cornell.edu (A SHOW OF HANDS) writes: > >for(i=0;a[i]=!'\0';i++) > printf("%c",a[i]); The above piece of code will set every character in the string "a" to a Control-A (ASCII code 001) and will continue past the end of the sting and wipe out your program. '\0' is zero !0 is one a[i] = !0 sets a[i] to one Note that the bad code has =! instead of !=. The correct code is for(i=0;a[i]!='\0';i++) { a bunch of "if" statements that handle special characters else printf("%c",a[i]); } -- Joe Smith (408)922-6220 | jms@antares.Tymnet.COM or jms@opus.Tymnet.COM McDonnell Douglas FSCO | UUCP: ...!{ames,pyramid}!oliveb!tymix!antares!jms PO Box 49019, MS-D21 | PDP-10:JMS@F74.Tymnet.COM CA license plate:"POPJ P," San Jose, CA 95161-9019 | narrator.device: "I didn't say that, my Amiga did!"