Issue with pointer to character array C++

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

    The error message is very clear; &buffer is of the type char (*)[9], i.e., a pointer to an array of char with 9 elements (yes, arrays are fully fledged types).

    That is not the same as a char*. However, arrays degrade to pointers to the first element when needed, so...

    char *pbuffer = buffer;
    

提交回复
热议问题