Re: getopt.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 05/05/15 15:10, Michael Kerrisk (man-pages) wrote:
On 05/01/2015 12:10 AM, Jonny Grant wrote:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

int
        main(int argc, char *argv[])
{
    int flags, opt;
    int nsecs, tfnd;

    nsecs = 0;
    tfnd = 0;
    flags = 0;
    while ((opt = getopt(argc, argv, "nt:")) != -1) {
        switch (opt) {
        case 'n':
            flags = 1;
            break;
        case 't':
            nsecs = atoi(optarg);
            tfnd = 1;
            break;
        default: /* '?' */
            fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\n",
                    argv[0]);
            exit(EXIT_FAILURE);
        }
    }

     return 0;
}

It looks like you are looking at a (very) old version
of the page. That code does not match the example in
the current man page.

Apologies, unsure where I got that old code from.
Latest code compiles ok for me too.
Regards, Jonny
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux