Why does the index of a `char **` type give the whole string?

前端 未结 2 711
天命终不由人
天命终不由人 2021-01-27 09:14

Consider this snippet:

#include 

using std::cout;
using std::endl;

int main()
{
    char c[] = {\'a\',\'b\',\'c\',\'\\0\'};
    char *pc = c;
           


        
2条回答
  •  清歌不尽
    2021-01-27 09:29

    These are equivalent:

    cout << ppc[0] << endl;
    cout << *( ppc + 0 ) << endl;
    cout << *ppc << endl;
    cout << *(&pc) << endl;
    cout << pc << endl;
    

提交回复
热议问题