Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 01 Feb 1998 23:12:28 +0200
From:      Ruslan Shevchenko <Ruslan@Shevchenko.kiev.ua>
To:        grobin@accessv.com
Cc:        questions@FreeBSD.ORG
Subject:   Re: Can't getopt().
Message-ID:  <34D4E539.2EC001E5@Shevchenko.kiev.ua>
References:  <34D6150D.2FD35180@accessv.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Geoffrey Robinson wrote:

> I probably shouldn't keep posting my C questions to this list but I'm
> stumped on this command and don't know anybody who can help.
>
> The program below should print the first command line argument but when
> I try to compile it I get the errors 'argc' undeclared and 'argv'
> undeclared. I've been through the getopt man page dozens of times but I
> can't see where it shows how to declare argc and argv. So if they're not
> defined in stdlib.h I don't know where they come from.
>
> #include <stdio.h>
> #include <stdlib.h>
>
> main()
> {
>    extern char *optarg;
>    extern int optind;
>    int ch = 0;
>
>    ch = getopt(argc, argv, "abcdefghijklmnopqrstuvwxyz");
>    printf ("%c\n",ch);
> }
>
> At this point I'm so frustrated with this I would be happy with a way of
> just getting the command line arguments as a single string and decode
> them myself.
>

OR:  main(int argc, char**argv)

OR
 extern int _argc;
 extern char** _argv;

  which is not reccomended.

> Thanks.
>
> --
> Geoffrey Robinson
> grobin@accessv.com
> Oakville, Ontario, Canada.



--

    @=
     //RSSH                              mailto://Ruslan@Shevchenko.Kiev.UA






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?34D4E539.2EC001E5>