What is the difference between “char *var[3]” and “char var[3][15]”?

前端 未结 4 718
栀梦
栀梦 2021-01-23 14:13

I am confused between the following two ways:

char var[3][15] = {\"Hello_world!\", \"good\", \"bad\"}; // as known this is for an 2D array.  
char *var[3] = {\"H         


        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-23 14:50

    The first is a 2D array of chars. The second is a 1D array of char * (pointers).

提交回复
热议问题