title: C - Structure's pointer
body: <p>I'm having trouble understanding <strong>pointers</strong> in general I think.
  I can't seem to follow the logic of this code:</p>
  
  <pre><code>    typedef struct StackRecord
  {
      int Capacity;
      int TopOfStack;
      int* Array;
  }*Stack;
  </code></pre>
  
  <p>In the following structure, <strong>*Stack</strong> was declared to receive addresses of <strong>StackRecord</strong> structure type via simply stating <strong>Stack</strong> due to typedef</p>
  
  <p>BUT code below the return another receiver of addresss of <strong>StackRecord</strong> structure type. Why isn't it returning the address? But rather return same type of pointer to itself?</p>
  
  <pre><code>Stack CreateStack(int MaxElements)
  {
      Stack S;
  
      if (MaxElements &lt; MinStackSize)
      {
          printf("Error : Stack size is too small");
          return 0;
      }
      S = (Stack)malloc(sizeof(struct StackRecord));
  
      if (S == NULL)
      {
          printf("FatalError : Out of Space!!!");
          return 0;
      }
  
      S-&gt;Array = (int*)malloc(sizeof(char)* MaxElements);
  
      if (S-&gt;Array == NULL)
      {
          printf("FatalError : Out of Space!!!");
          return 0;
      }
      S-&gt;Capacity = MaxElements;
      MakeEmpty(S);
  
      return S;
  }
  </code></pre>