title: Populating values to a pointer array
body: <p>Off lately I have taken up the task to understand and learn C. Right now I was learning about structures and pointer arrays. I have a problem. I want to populate a pointer array with values. Below is my code:</p>
  
  <pre><code>           struct profile_t 
            {
             unsigned char length;
             unsigned char type;
             unsigned char *data;
            };
  
            typedef struct profile_datagram_t
           {
            unsigned char src[4];
            unsigned char dst[4];
            unsigned char ver;
            unsigned char n;
            struct profile_t profiles[MAXPROFILES];       
           } header;
  
            header outObj;
  
           int j =0;
           int i =0;
  
        outObj.profiles[j].data = malloc(10);
  
        for(i=0;i&lt;10;i++)
            {
           if (j=0)
               {
             outObj.profiles[j][i] = 1 2 3 4 5 6 7 8 9 10;
           }
           else 
               {
          j=1;
           }
        }
  
        for(i=0;i&lt;10;i++)
            {
          if (j=1)
              {
             outObj.profiles[j][i] = 1 2 3 4 5 6 7 8 9 10;
          }
        }
  </code></pre>
  
  <p>Is the above approach the way to go or am I completely offtrack. MAXPROFILES is 2 (which means only 0 and 1).</p>