On Mar 26, 2007, at 9:08 AM, Herbert Graf wrote: >> I think I've always found the: >> while ( (c=getchar(file)) > 0) { >> /* do stuff with c */ >> } >> slightly clearer than the versions that separate the assignment >> from the check... > > Similarly when dealing with pointers, I fine the "one line" much more > understandable, i.e.: > > if ((file_handle=fopen(stuff)) == NULL) > Of course, these are really due to weaknesses in the usual libraries. Using a "special" return value to indicate an error condition on a function that ought to be returning a character or structure pointer is rather gross. But the use of NULL pointers for such cases is deeply entrenched in the unix mindset, and really dangerous stuff like getchar() is "historical" (IIRC, we broke out getchar() equiv when we went to a compiler that supported function prototypes. I mean, it returns a char, right? (nope! All sorts of 8bit and BREAK support died real quick.)) if (fopen(stuff, &myfile) != OK) then { /* open error */ } while (!fileerror(myfile)) { c = getchar(myfile); : } BillW -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist