Issue with pointer to character array C++

前端 未结 6 868
醉梦人生
醉梦人生 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:33

    Name of array indicates it's base address, so if you just write buffer, it means address of buffer[0]. If you are using &buffer, you need to take it in char** not in char *.

    So,

    char* pBuffer = buffer;
    

    Would be correct as suggested.

提交回复
热议问题