Q:

Returning merged arrays from function in C

I have the following code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

typedef struct _item {
    int v, w;
} item;

void printItems(item *t, int n) {
int i;
    for(i= 0; i < n; i++)
    printf("%4i",t[i].v);
    printf("\n");
}

item * newItemSet(int n) {
    int i;
    item *t = (item*)malloc(sizeof(item));
    for (i = 0; i < n; i++){
        (t+i)->v = rand()%100;
        (t+i)->w = rand()%100;
    }
    return t;
}

item * mer(item*a, int n, item*b, int m) {
    int size = m+n;
    item*q = (item*)malloc(sizeof(item)*size);
    int i, c;
    c = 0;
    printf("a----\n");
    printItems(a,n);
    printf("b----\n");
    printItems(b,m);
    for(i = 0; i<n; i++) {
        q[c] = a[i];
        c++;
    }
    for(i = 0; i<m; i++) {
        q[c] = b[i];
        c++;
    }
    printItems(q,size);
    return q;
}   

int main(void) {
    srand(time(NULL));
    item * a = newItemSet(6);
    item *b = newItemSet(6);
    item *c = mer(a,6,b,6);
    printItems(c,12);   
    return 0;
}

At every execution, the first part of c is correct, up to the last two elements of b. What did I miss? 

A:

The allocation for newItemSet does not appear correct.  It should be:
item *t = malloc(sizeof(item) * n);

