why i can not convert a char ** to a const char ** ?

Discussion in 'C Programming' started by Steven Woody, Jan 14, 2006.

  1. Steven Woody

    Steven Woody Guest

    somewhere in my code,

    char* rtnStrs[] = { "ok", "error", NULL };
    foo( rtnStrs );

    here, foo was decleared as 'void foo( const char * rtnStrs[] ).

    but the gcc compiler will report ' can not convert from char ** to
    const char ** '. i usually know that one can not convert a const to a
    non-const, but why here i can not convert a non-const to const ?

    thanks.

    -
    woody
    Steven Woody, Jan 14, 2006
    #1
    1. Advertising

  2. Steven Woody

    Michael Mair Guest

    Steven Woody wrote:
    > somewhere in my code,
    >
    > char* rtnStrs[] = { "ok", "error", NULL };
    > foo( rtnStrs );
    >
    > here, foo was decleared as 'void foo( const char * rtnStrs[] ).
    >
    > but the gcc compiler will report ' can not convert from char ** to
    > const char ** '. i usually know that one can not convert a const to a
    > non-const, but why here i can not convert a non-const to const ?


    RTFFAQ: It is only polite to have a look into the FAQ before
    posting...

    http://c-faq.com/ansi/constmismatch.html

    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.
    Michael Mair, Jan 14, 2006
    #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. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,665
    Smokey Grindel
    Dec 2, 2006
  2. Replies:
    24
    Views:
    799
    Netocrat
    Oct 30, 2005
  3. lovecreatesbeauty
    Replies:
    1
    Views:
    990
    Ian Collins
    May 9, 2006
  4. Gernot Frisch

    can't convert char* to const char* !?

    Gernot Frisch, Sep 25, 2006, in forum: C++
    Replies:
    2
    Views:
    1,917
    Kaz Kylheku
    Sep 25, 2006
  5. Javier
    Replies:
    2
    Views:
    532
    James Kanze
    Sep 4, 2007
Loading...

Share This Page