hhg1@GTE.COM (Hallett German) (07/13/89)
This is my first and probably last note for this group. My question is concerning argv manipulation. There appears to be 2 general ways to do this: 1. Pointer manipulation and use a switch on what appears after the -. An example appears on K&R 2 page 117. 2. Use strcmp and compare -F with argv[1]. And use other functions like getopt. My questions are: 1. Which do most people use and why? 2. Is there a good reference just on this subject? I am sorry if this is a basic question but I haven't seen an answer to it the three months I've been reading this generally insightful group. Hal German GTE Labs Waltham, Ma 02254 NESUG BBS: 617-263-1499 M&Tu 7:00 -6:30 pm 1200 or 2400 8N1
henry@utzoo.uucp (Henry Spencer) (07/14/89)
In article <7292@bunny.GTE.COM> hhg1@GTE.COM (Hallett German) writes: > And use other functions like getopt. Using getopt is the right way to do it, unless there are *compelling* reasons to do otherwise (notably, backward compatibility with a program that uses non-standard syntax). It is an enormous win to have standard, predictable syntax for options. Getopt, for all its warts, accomplishes that, without breaking the whole world (which is what attempts at syntax reform end up doing, which is why they always fail). The one wart of getopt is that it's a bit awkward to use "cold". The most effective way is to type in the example from the getopt manual page *once* and use that as a template, modifying a copy of it rather than trying to type it in from scratch each time. -- $10 million equals 18 PM | Henry Spencer at U of Toronto Zoology (Pentagon-Minutes). -Tom Neff | uunet!attcan!utzoo!henry henry@zoo.toronto.edu