Issue with pointer to character array C++

前端 未结 6 872
醉梦人生
醉梦人生 2020-12-11 03:10

I have what I thought should be a very simple snippet of code to write, though I\'m unable to compile for a reason which I do not understand.

The following simplifie

6条回答
  •  我在风中等你
    2020-12-11 03:35

    because the compiler can't implicitly convert char()[] to char. So you need explicit type conversion

    char buffer[9] = "12345678";
    char* pBuffer = (char*)&buffer;
    

提交回复
热议问题