Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef int data;
- struct ArrayN_Dimension{
- struct ArrayN_Dimension *nextDim;
- data *array;
- };
- data* getDimension(struct ArrayN_Dimension *head, int dim)
- {
- if (dim < 0)
- return NULL;
- if (dim == 0)
- return head->array;
- else if (head->nextDim == NULL)
- return NULL;
- else
- return getDimension(head->nextDim,dim-1);
- }
- void createarray(struct ArrayN_Dimension *head, int n)
- {
- if (n < 0)
- return;
- if (n == 0)
- return;
- head = malloc(sizeof(struct ArrayN_Dimension));
- head->nextDim = NULL;
- head->array = malloc(n*sizeof(data));
- createarray(head->nextDim,n-1);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement