Newbie problem with **argv

Discussion in 'C++' started by Vio, May 14, 2004.

  1. Vio

    Vio Guest

    I want to call this function, whose prototype is:

    extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, wxChar **argv);

    I want to ignore both arguments essenially. My problem is with **argv.
    In C this is called a handle to a struct. In C++ I don't know. But
    mostly I suck at pointers, messing these up.
    So, my question is: How do I initialize **argv in my call?
    Things like following don't seem to work:

    wxEntryStart(int argc=0, char *argv[]=NULL);
    My choice:
    wxEntryStart(0, NULL);

    or:
    char *argv[];//=";";
    argv[0]=" ";
    bool wxEntryStart(int argc=0, *argv);//wxEntryStart(int& argc, wxChar
    **argv)

    b1.cpp:142: ANSI C++ forbids declaration `argv' with no type
    b1.cpp:142: conflicting types for `int argv[0]'
    b1.cpp:141: previous declaration as `char * argv[]'
    b1.cpp:142: invalid initializer
    b1.cpp:143: type specifier omitted for parameter
    make: *** [b1.o] Error 1


    Much obliged for your help,
    Vio
    Vio, May 14, 2004
    #1
    1. Advertising

  2. Vio

    Rolf Magnus Guest

    Vio wrote:

    > I want to call this function, whose prototype is:
    >
    > extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, wxChar **argv);
    >
    > I want to ignore both arguments essenially. My problem is with **argv.
    > In C this is called a handle to a struct.


    There is no such thing as 'handle' in standard C. argv is a pointer to
    pointer to wxChar, **argv is a wxChar.

    > In C++ I don't know.


    It's the same as in C.

    > But mostly I suck at pointers, messing these up.
    > So, my question is: How do I initialize **argv in my call?
    > Things like following don't seem to work:
    >
    > wxEntryStart(int argc=0, char *argv[]=NULL);
    > My choice:
    > wxEntryStart(0, NULL);


    This should work, though:

    wxEntryStart();

    would be enough. That's why you gave default values for your parameters
    in the first place.

    > or:
    > char *argv[];//=";";


    The above line is illegal, because you can't define arrays that have no
    size.

    > argv[0]=" ";


    For this, the argv array would at least have to have one element.

    > bool wxEntryStart(int argc=0, *argv);


    This isn't a valid function call. Make it soemthing like:

    bool ret = wxEntryStart(0, argv);

    *argv would be a pointer to char, but you have to supply argv itself,
    which is a pointer to pointer to char.
    Rolf Magnus, May 14, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bret

    char **argv vs. char* argv[]

    Bret, Aug 31, 2003, in forum: C Programming
    Replies:
    21
    Views:
    4,582
    Richard Heathfield
    Sep 3, 2003
  2. David
    Replies:
    10
    Views:
    5,950
    Richard Heathfield
    Sep 15, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    1,629
    Old Wolf
    Jan 20, 2004
  4. =?ISO-8859-1?Q?Thomas_N=FCcker?=

    sys.argv[0] - 'module' object has no attribute 'argv'

    =?ISO-8859-1?Q?Thomas_N=FCcker?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    901
    =?ISO-8859-1?Q?Thomas_N=FCcker?=
    Jun 30, 2003
  5. jab3

    char **argv & char *argv[]

    jab3, Dec 4, 2004, in forum: C Programming
    Replies:
    5
    Views:
    665
    Chris Torek
    Dec 8, 2004
Loading...

Share This Page