Here's my problem : 

I have a program where the user have to fill this : 

* a 2d array of a list of elements from which i can at most take one element ( we'll call it exclusionArr )
* a 2d array of a list of elements from which i have to at least take one element ( we'll call it inclusionArr )
* an array with the elements i have to keep ( we'll call it keepArr )
* an array with the elements i can't use ( we'll call it throwArr )

Now on the first step i need to check if any row of exclusionArr contain an element of keepArr and if it does then i need to add every element of that row but that one in throwArr.

One row cannot contain more than one element of keepArr, i'll make a function to check for that and return an error if it is. ( you can at most keep one item from the rows of exclusionArr so having 2 elements of keepArr on the same row is a problem )

I need help to add element to an array, i can't seem to be able to store those values in my array (more like i don't really know how to, still new to C).

Here's the function i made so far :

```
void interdiction(int *throwArr[], int *throw_size, int keepArr[], int keep_size, int x, int y, int exceptionArr[x][y]) {
    int i, j, k, count=0;
    while(count<keep_size) {
        for(i=0;i<x;i++) {
            for(j=0;j<y;j++) {
                if (exceptionArr[i][j] == keepArr[count]) {
                    for (k=0;k<y;k++) {
                        if(k!=j) {
                            printf("\nElement %d of exclusion %d inserted in throwArr",exceptionArr[i][k], i);
                            *throw_size+=1;
                            throwArr[*throw_size]=exceptionArr[i][k];
                        }
                        else printf("\nelement to keep found in exclusion %d in position %d", i, j);
                    }
                }
            }
        }
        count++;
    }
}

```

I would like it to change the throwArr that i put in the function so that it adds on the already existing array every element on the current row except the element that's in keepArr.

I don't know if it's relevant or not but for throwArr when initializing it i allocate a lot of extra memory so i could perform changes without running out of space so i don't know if i need to realloc memory in the function for the changes done.

Any help would be greatly appreciated !

EDIT : Here's the full code

```
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

void interdiction(int *throwArr, int throw_size, int *keepArr, int keep_size, int x, int y, int exclusionArr[x][y]);
static int compare (void const *a, void const *b);
void noDuplicate( int arr[], int *size );
void xclusion_alloc (int x, int y, int(**aptr)[x][y]);
void xclusion_print (int x, int y, int array[x][y]);
void xclusion_fill (int x, int y, int array[x][y]);

void main(){
    int throw_size, keep_size, rexc, lexc;
    int i, j;
    int  nbObjets=7, *throwArr, *keepArr, (*exclusionArr)[rexc][lexc];

    printf("\nHow many exclusions :");
    scanf("%d", &rexc);
    printf("\nHow many elements in each exclusion :");
    scanf("%d", &lexc);
    xclusion_alloc(rexc,lexc,&exclusionArr);
    xclusion_fill(rexc,lexc,*exclusionArr);
    xclusion_print(rexc,lexc,*exclusionArr);

    printf("\nHow many elements do we have to keep :");
    scanf("%d", &keep_size);
    keepArr=malloc(nbObjets*sizeof(int));
    printf("\nWhat are they :");
    for(i=0;i<keep_size;i++){
        scanf("%d",&keepArr[i]);
    }
    qsort(keepArr, keep_size, sizeof *keepArr, compare);
    noDuplicate(keepArr, &keep_size);

    printf("\nHow many elements we can't use :");
    scanf("%d", &throw_size);
    throwArr=malloc(nbObjets*sizeof(int));
    printf("\nWhat are they :");
    for(i=0;i<throw_size;i++){
        scanf("%d",&throwArr[i]);
    }
    qsort(throwArr, throw_size, sizeof *throwArr, compare);
    noDuplicate(throwArr, &throw_size);

    interdiction(throwArr, throw_size, keepArr, keep_size, rexc, lexc, *exclusionArr);
    printf("\nOur array of elements we can't use : ");
        for (i=0;i<throw_size;i++){
        printf("%d ", throwArr[i]);
        }

}

static int compare (void const *a, void const *b){
   int const *pa = a;
   int const *pb = b;
   return *pa - *pb;
}

void interdiction(int *throwArr, int throw_size, int *keepArr, int keep_size, int x, int y, int exclusionArr[x][y]){
    int i, j, k, count=0;

    while(count<keep_size){
        for(i=0;i<x;i++) {
            for(j=0;j<y;j++) {
                if (exclusionArr[i][j] == keepArr[count]) {     
                for (k=0;k<y;k++){
                    if(k!=j){
                    printf("\nElement %d of exclusion %d inserted in the array of elements we can't use",exclusionArr[i][k], i);
                    throw_size+=1;
                    throwArr[throw_size]=exclusionArr[i][k];            
                    }
                    else printf("\nelement to keep found in exclusion n°%d in position %d", i, j);
                }
                }
            }
        }
    count++;
    }
}

void noDuplicate( int arr[], int *size ) {
    int i=0, j=0;

    for (i = 1; i < *size; i++) {
        if (arr[i] != arr[j]) {
            j++;
            arr[j] = arr[i]; 
        }
   }

    *size = (j + 1);

}

void xclusion_alloc (int x, int y, int(**aptr)[x][y]) {

    *aptr = malloc( sizeof(int[x][y]) ); 
    assert(*aptr != NULL);
}

void xclusion_fill (int x, int y, int array[x][y]) {
    int i, j;

    for(i=0; i<x; i++) {
        for(j=0; j<y; j++) {
            scanf("%d", &array[i][j]);
            }
        }
}

void xclusion_print (int x, int y, int array[x][y]) {
    int i,j;

    for(i=0; i<x; i++) {
        printf("\nExclusion n°%d :", i);
        printf(" { ");
        for(j=0; j<y; j++) {
            printf("%d ", array[i][j]);
        }
        printf("}");
        printf("\n");
    }
}

```

Sadly the output i'm getting is like this : 

```
How many exclusions :3

How many elements in each exclusion :2
5 3
2 7
4 1

Exclusion n░0 : { 5 3 }

Exclusion n░1 : { 2 7 }

Exclusion n░2 : { 4 1 }

How many elements do we have to keep :1

What are they :5

How many elements we can't use :1 2

What are they :
element to keep found in exclusion n░0 in position 0
Element 3 of exclusion 0 inserted in the array of elements we can't use
Our array of elements we can't use : 2

```