title: Allocate memory for a struct in a function
body: <p>I need to make an adfgx machine (<a href="http://en.wikipedia.org/wiki/ADFGVX_cipher" rel="nofollow">Code language from WWII</a>) for a project in school. But I am running into some problems.</p>
  
  <p>There is a struct along with some functions defined in adfgx.h which looks like this:</p>
  
  <pre><code>typedef struct {
     char* alphabet;         
     char* symbols;          
     char* dictionary;       
     char* transposition;    
  } adfgx;
  </code></pre>
  
  <p>In adfgx.c we include the header and I have to write a function that allocates memory for this struct with a predefined signature:</p>
  
  <pre><code>/* Creates a new ADFGX machine */
  adfgx* create_adfgx(const char* alphabet, const char* symbols, const char* dictionary, const char* transposition);
  </code></pre>
  
  <p>So what I am supposed to do here is allocate memory for the struct in that function. I don't get how I am supposed to do this, because I don't now the size of alphabet, symbols, dictionary and transposition, so how can I now hom much memory I need to allocate?</p>