user48730: topicArray defined as follows:
const char* msgTopic = "Home/Messages";
const char* groupTopic = "Home/All";
char* deviceName = deviceTopic;
const char* topicArry[2] = {deviceTopic, groupTopic};

But deviceTopic can be changed during code run, and I wish that topicArray containg deviceTopic will have the correct value after deviceTopic has changed.
What is the right way doing so ?

user7508: You may try something like this:
const char* topicArry[2] = {NULL, groupTopic};
const char** const pDeviceTopic = &topicArry[0];
#define deviceTopic (*pDeviceTopic)

Arguably not very elegant, but now when you assign, e.g.
deviceTopic = msgTopic;

you are actually writing into topicArry[0].

48730: <p><code>topicArray</code> defined as follows:</p>

<pre><code>const char* msgTopic = "Home/Messages";
const char* groupTopic = "Home/All";
char* deviceName = deviceTopic;
const char* topicArry[2] = {deviceTopic, groupTopic};
</code></pre>

<p>But <code>deviceTopic</code> can be changed during code run, and I wish that <code>topicArray</code> containg <code>deviceTopic</code> will have the correct value after <code>deviceTopic</code> has changed.</p>

<p>What is the right way doing so ?</p>
 7508: <p>You may try something like this:</p>

<pre><code>const char* topicArry[2] = {NULL, groupTopic};
const char** const pDeviceTopic = &amp;topicArry[0];
#define deviceTopic (*pDeviceTopic)
</code></pre>

<p>Arguably not very elegant, but now when you assign, e.g.</p>

<pre><code>deviceTopic = msgTopic;
</code></pre>

<p>you are actually writing into <code>topicArry[0]</code>.</p>
