I am new to C programming. Can any body tell me how can I do the coding for the term in bold?
create a structure called arrayData that contains an integer pointer called array and an integer variable called size.
create a function with the following header: arrayData* createArray(int size). Inside this function you will malloc space for a new arrayData structure. You will then need to create an array using the input variable as the number of elements. Finally you will need to set the variables in the malloc'ed arrayData pointer equal to the array and the array size. Finally return the pointer of malloc'ed arrayData structure.
I have tried something like:
#include<stdio.h>
struct arrayData
{
int *array;
int size;
}
struct arrayData* createArray(int size)
{
struct arrayData *str = (struct arrayData*)malloc(sizeof(struct arrayData));
int a = 10;
int arr[a];
for ( a = 0; a < 10; a++ )
{
str->arr[i] = a;
}
return str;
}
arrayDatahas no memberarr.