Using char * in a struct or collection
<p>I'm a little confused how a <code>char *</code> is handled in memory for a collection or struct, that is, what is the responsibility to manage the memory. I've heard that in general it is not wise to rely on resource management and pointers when you have classes like <code>string</code> available instead.</p>

<p><code>std::tr1::unordered_map&lt;char*, Vars&gt; elements;</code></p>

<p>or</p>

<pre><code>struct example{
 char*name;
}
</code></pre>

<p>If you are technically passing a pointer to a character array, then this implies the "owning" collection or struct does not manage the memory for that piece of text, but rather just a pointer to it. So is it possible for that text to disappear from memory and the pointer to dangle?</p>

<p>For example:</p>

<pre><code>char * text="yo";
example myStruct;
myStruct.name=text; // how safe is this?
</code></pre>
