Using Malloc() to create an integer array using pointer : <p>I'm trying to create an integer array using the defined ADT below using the malloc() function. I want it to return a pointer to a newly allocated integer array of type intarr_t. If it doesn't work - I want it to return a null pointer. </p>

<p>This is what I have so far - </p>

<pre><code>//The ADT structure

typedef struct {
  int* data;
  unsigned int len;
} intarr_t;

//the function 

intarr_t* intarr_create( unsigned int len ){

    intarr_t* ia = malloc(sizeof(intarr_t)*len);
    if (ia == 0 )
        {
            printf( "Warning: failed to allocate memory for an image structure\n" ); 
            return 0;
        }
    return ia;
}
</code></pre>

<p>The test from our system is giving me this error </p>

<pre><code>intarr_create(): null pointer in the structure's data field
stderr 
(empty)
</code></pre>

<p>Where abouts have I gone wrong here?</p>
