user48870: I have something being returned as a const char* and would like to save it to an array.
I've tried this:
const char* book[amtBooks] = "";

and get this error:
error: array must be initialized with a brace-enclosed initializer


user7508: 
const char* book[amtBooks] is an array of pointers.
"" is an array of chars (with only a NUL character).

You can initialize an array of chars with an array of chars:
const char foo[] = "hello";

You can also initialize a pointer to char with an array of chars:
const char *bar = "good bye";

this works because of the “decay to pointer” feature of C and C++.
But initializing an array of pointers with an array of chars simply does
not make sense. An array of pointers to char could be initialized as
const char *book[] = {"hello", "good bye"};


48870: <p>I have something being returned as a const char* and would like to save it to an array.</p>

<p>I've tried this:</p>

<pre><code>const char* book[amtBooks] = "";
</code></pre>

<p>and get this error:</p>

<pre><code>error: array must be initialized with a brace-enclosed initializer
</code></pre>
 7508: <ul>
<li><code>const char* book[amtBooks]</code> is an array of pointers.</li>
<li><code>""</code> is an array of chars (with only a NUL character).</li>
</ul>

<p>You can initialize an array of chars with an array of chars:</p>



<pre class="lang-c++ prettyprint-override"><code>const char foo[] = "hello";
</code></pre>

<p>You can also initialize a pointer to char with an array of chars:</p>

<pre class="lang-c++ prettyprint-override"><code>const char *bar = "good bye";
</code></pre>

<p>this works because of the “decay to pointer” feature of C and C++.</p>

<p>But initializing an array of pointers with an array of chars simply does
not make sense. An array of pointers to char could be initialized as</p>

<pre class="lang-c++ prettyprint-override"><code>const char *book[] = {"hello", "good bye"};
</code></pre>
