mardi 30 décembre 2014

How to initialize the dynamic array of chars with a string literal in C++?

I want to do the following:



std::unique_ptr<char[]> buffer = new char[ /* ... */ ] { "/tmp/file-XXXXXX" };


Obviously, it doesn't work because I haven't specified the size of a new array. What is an appropriate way to achieve my goal without counting symbols in a string literal?


Usage of std::array is also welcome.


Update #1: even if I put the size of array, it won't work either.


Aucun commentaire:

Enregistrer un commentaire