Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Like I said in my comments above, it's not possible to give a precise answer, because it's not clear what the aim is here. But I see two possibilities:</p> <p><strong>1: <code>target</code> is pointing at a <code>char</code> buffer</strong></p> <p>If this is the case, then it would seem that you'll need to copy the contents of your string into that buffer. This is not possible to do safely, because you don't know how big the receiving buffer is. But if you don't care about that, then you need to do something like:</p> <pre><code>strcpy((char *)target, c-&gt;hostname); </code></pre> <p><strong>2: <code>target</code> is pointing at a <code>char *</code></strong></p> <p>If this is the case, then the intention is presumably either to modify that <code>char *</code> to point at the existing string, or to dynamically create a new buffer, copy the string, and then modify the <code>char *</code> to point at it.</p> <p>So either:</p> <pre><code>char **p = (char **)target; *p = c-&gt;hostname; </code></pre> <p>or:</p> <pre><code>char **p = (char **)target; *p = malloc(strlen(c-&gt;hostname)+1); strcpy(p, c-&gt;hostname); </code></pre> <p><strong>Note</strong></p> <p>You get the warning message because in this line:</p> <pre><code>*hostname = c-&gt;hostname; </code></pre> <p><code>*hostname</code> is of type <code>char</code>, whereas <code>c-&gt;hostname</code> is of type <code>char *</code>. The compiler is telling you that this conversion doesn't make any sense. If I were you, I would set your compiler up to treat warnings as errors (e.g. with the <code>-Werror</code> flag for GCC), because warnings should always be adhered to!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload