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

S

Steven Woody

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
 
M

Michael Mair

Steven said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top