title: How to work with string fields in a C struct?
body: <p>I'm having trouble making a database based on a singly-linked list in C,
  not because of the linked list concept but rather the string fields in the struct themselves.</p>
  
  <p>This is an assignment in C and as far as I know (I'm a newbie), C doesn't recognize 'string' as a data type. </p>
  
  <p>This is what my struct code looks like:</p>
  
  <pre><code>typedef struct 
  {
    int number;
    string name;
    string address;
    string birthdate;
    char gender;
  } patient;
  
  typedef struct llist
  {
    patient num;
    struct llist *next;
  } list;
  </code></pre>
  
  <p>I was thinking of making a struct for the strings themselves so that I can use them in the struct, like this:</p>
  
  <pre><code>typedef struct string 
  { 
    char *text;
  } *string;
  </code></pre>
  
  <p>Then I will <code>malloc()</code> each one of them when it is required to make new data of the string type (array of char).</p>
  
  <pre><code>typedef struct string
  {
    char *text;
  } *string;
  
  int main()
  {
      int length = 50;
      string s = (string) malloc(sizeof string);
      s-&gt;text = (char *) malloc(len * sizeof char);
      strcpy(s-&gt;text, patient.name-&gt;text);
  }
  </code></pre>
  
  <p>Can someone help me figure this out?<br>
  Thank you.</p>