Pang wrote: > Thanks Brian and Neil, I will take note on the advice of good coding. I > guess the only confusion here is whether 'argv' is an array name or a > pointer. The whole structure is in MAIN, so my understanding was that it is > an array name, and as such operation like assignment and increment are > illegal. But base on the example, the 'argv' has to be a pointer to be okay. This is how i view it. argv is a pointer to an array of pointers. each element in the array of pointers then point to each argument. argv arrayof pointers the argument in the command-line [] - > [] -> [filename] [] -> [option 1] [] -> [option 2] hope this clear things up. K&R2 does tell you to avoid this type of expression due to it's unnature brevity. Regards, John Chung > > correct. > > Thanks again. > > Pang > > ----- Original Message ----- > From: "Neil Bradley" > To: > Sent: Tuesday, April 08, 2003 1:25 PM > Subject: Re: [OT]:C pointer Question > > > > There is a line of code at that section - > > > > > > 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. > > > > Note the first (*++argv)[0] means that argv gets ++'d, so it moves past > > argv[0] to argv[1]'s address (skipping past the launch filename). > > > > Now when you do c = *++argv[0], that will increment the pointer of > > argv[1] by 1, skipping past the '-'. > > > > Code like the above is highly unreadable (hence your message), and authors > > of such atrocities should be taken out and maimed, shot, and otherwise > > tortured. ;-) (yes, I know it's K&R, but they weren't the best coders in > > the world). > > > > -->Neil > > > > -------------------------------------------------------------------------- > ----- > > Neil Bradley In the land of the blind, the one eyed man is not > > Synthcom Systems, Inc. king - he's a prisoner. > > ICQ #29402898 > > > > -- > > 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 -- 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