dimanche 26 février 2017

How to assign memory using shared pointer instead of malloc for char array

I have a character array and I want to initialize it using shared pointer I wrote like this below, but getting syntax error. Can anyone suggest what needs to be modified to make this work. I want the size of the array based on the rows and column. The maparray will hold bunch characters of '*'. Something like:

***
* *
***

 std::shared_ptr<unsigned char*> maparray;
 maparray=std::make_shared<unsigned char*>(rows*cols);

Aucun commentaire:

Enregistrer un commentaire