Issue with pointer to character array C++

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

    array decays to pointer, you only need

    char* pBuffer = buffer;
    

    Also checkout: std::decay

       std::cout << "int[] -> int*; // " << std::boolalpha
                  << std::is_same::type>::value;
    

    Output:

    int[] -> int*; // true
    

提交回复
热议问题