title: struct member character by character in c
body: <p>How can I assign values to struct member <em>character by character</em>. I would like to do something like</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  struct s
  {
      char  *z; 
  };
  
  int main ()
  {
  
     struct s *ss;
     ss = malloc(2 * sizeof *ss);
  
     char *str = "Hello World-Bye Foo Bar";
     char *a = str;
     int i = 0;
     while (*a != '\0') {
         if (*a == '-')
             i++;
         else ss[i].z = *a; // can I do this?
         a++;
     }   
     for(i = 0; i&lt;2; i++)
        printf("%s\n",ss[i].z);
  }
  </code></pre>
  
  <p>So I can get something as:</p>
  
  <pre><code>ss[0].z = "Hello World"
  ss[1].z = "-Bye Foo Bar"
  </code></pre>
  
  <p><strong>Edit:</strong> Forgot to mention, the number of "-" in <code>str</code> might vary.</p>