title: Array of structures initialization while doing typedef
body: <p>Given a structure that represents a point as following:</p>
  
  <pre><code>typedef struct p
  {
      char c;
      float x,y;
  }P[2];
  </code></pre>
  
  <p>How to define and initialize an array that represents the line with points <code>A(1,0)</code> and <code>B(3,0)</code>?</p>
  
  <p>In the following code, it says <code>typedef 'P' is initialized (use typeof instead)</code>:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  typedef struct p
  {
      char c;
      float x,y;
  }P[2]={{'A',1.0,2.0},{'B',3.0,4.0}};
  int main()
  
  {
      printf("\n %c %f %f",P[0].c,P[0].x,P[0].y);
      printf("\n %c %f %f",P[1].c,P[1].x,P[1].y);
      return 0;
  }
  </code></pre>
  
  <p>The following works, but it changes the definition of a structure:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  typedef struct p
  {
      char c;
      float x,y;
  }point;
  point P[2]={{'A',1.0,2.0},{'B',3.0,4.0}};
  int main()
  
  {
      printf("\n %c %f %f",P[0].c,P[0].x,P[0].y);
      printf("\n %c %f %f",P[1].c,P[1].x,P[1].y);
      return 0;
  }
  </code></pre>
  
  <p>How to initialize this array without changing the definition of structure:</p>
  
  <pre><code> typedef struct p
  {
      char c;
      float x,y;
  }P[2]; 
  </code></pre>