title: Copy a string to a *struct member
body: <p>I've looked through topics of similar kind, but didn't find a solution for my problem. I've got a struct like</p>
  <pre><code>typedef struct {
      int number;
      char *string;
  } mystruct;
      
  //Then define a pointer to the struct:
  mystruct *data;
      
  // Allocate memory:
  data = malloc(sizeof(mystruct));
      
  //Assign some number, let's say 5:
  (*data).number = 5;
      
  //So far ok, works (checked: 5 can be retrieved from the struct somewhere else) but:
      
  strcpy((*data).string = &quot;Hello!&quot;);
  //This line fails with segmentation fault.
  </code></pre>
  <p>I don't understand why? Can somebody please explain what I'm doing wrong?</p>