C++ char*[] to char** conversion

后端 未结 3 2010
鱼传尺愫
鱼传尺愫 2021-02-19 01:00

I have this simple code that compiles without errors/warnings:

void f(int&, char**&){}

int main(int argc, char* argv[])
{
    f(argc, argv);
    return          


        
3条回答
  •  旧巷少年郎
    2021-02-19 01:22

    The type of temp in

    char* temp[] = { "", "", nullptr };

    is not char*[], it's

    char*[3]

    The latter can't be implicitly converted to `char**'.

    In main, the type of argv is an unbound char* array which is equivalent to char**

    I admit, it's confusing :)

提交回复
热议问题