I am supposed to write a shell using C, and someone told me that there is a good command to help with parsing the command line, but I cannot find it. I have never programmed in C before and I was wondering if anyone had some pointers (hehe).
I think that they want me to run the program, and then type things after the program is running already and get the arguments. That way, I can't just use the argv[] options.
Michyrec, I bet the command you need is 'getopt'. This is a command that can process arguments that consist of flag arguments and value arguments. Flag arguments are a dash immediately followed by a single character, ie '-a'. Value arguments are a flag argument followed by an optional space character followed by some value argument. Using an example may help.
Code:
ping -a -c 5
In this command, the '-a' is a flag and the '-c 5' is a value.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.