Hi, Before you get too carried away with beating up on K&R you must remember the initial target (PDP-10) for the C language. At that time compilers were no where near as sophisticated as they are now and often tight code like that translated literally to a few lines of assembler. Code that was more human readable often generated assembler that was much much larger. You see the difference in languages like Pascal. The compiler creates the same instruction for a P := P + 5; as a C compiler does for C += 5; And when you think about it, given that assignments were two character tokens, the Pascal language should have had P += 5; But, in either case, for PIC micro-processors, it's really important to study the assembler created by the various C expressions and statements. You'll quickly find the techniques that make the tightest code and that will be the way you program. And someone will take you to task for not writing it in a more readable version. Of course when the application reaches 8193 words and there are only 8192 available, efficiency suddenly rules. Cheers, John Dammeyer Wireless CAN with the CANRF module now available. http://www.autoartisans.com/products Automation Artisans Inc. Ph. 1 250 544 4950 > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Brian Smith > Sent: Monday, April 07, 2003 10:32 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [OT]:C pointer Question > > > > while ( --argc > 0 && ( *++argv ) [0] == '-' ) > > while ( c= *++argv [0] ) > > switch (c) {.......} > > > > I do not understand the portion c = *++argv[0]. From what i > understand, > > the > > 'result' of that incrementing and dereferencing will be c = > argv[0][1], > > which is wrong. > > That line increments the argv pointer, dereferences it once, then > dereferences it again to compare the byte to '-'. > > You could replace that while expression with this: > while (1) > { > argc--; > if (argc <= 0) > break; > argv++; > if (argv[0][0] != '-') > break; > > > > > Shouldn't the line be replaced with c = *++argv[1] ? > > FYI, > > argv[0] = pointer to array of char "find" > > argv[1] = pointer to array of char "-nx" > > argv[2] = pointer to array of char "pattern" > > The source appears to be correct. You should examine > the operator precedence rules. They are a pain, but > crucial to understanding cryptic code like this. > > OK, on with the soap box. Bear with me? Please > do not write code like this. Parentheses are your > friend! Just because some can understand this code > does not mean that most programmers will. It took me > a bit to understand it, so I know that a fresh > graduate is not going to be able to easily maintain > code written in this style. Be nice to your > co-workers. :-) > > Brian > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics