how to return two dimensional char array c++?

前端 未结 8 2135
攒了一身酷
攒了一身酷 2020-12-03 15:23

i ve created two dimensional array inside a function, i want to return that array, and pass it somewhere to other function..

char *createBoard( ){  
  char          


        
8条回答
  •  一整个雨季
    2020-12-03 15:43

    You must not return a pointer to a functions local variables because this space gets overwritten as soon as the function returns.

    The storage associated with board is on the function's stack.

提交回复
热议问题