title: C - join arrays
body: <p>why can't i use Join? it doesn't have the 4 (e) from set B... why?</p>
  
  <pre>
  #include &lt;stdio.h&gt;
  
  #define SIZEOF_A 6
  #define SIZEOF_B 6
  
  typedef enum {
          a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
  } set;
  
  void dispSet(set numbers[], int size_numbers) {
    int i;
    printf("[ ");
    for (i = 0; i &lt; size_numbers-1; i++) {
      printf("%d, ", numbers[i]);
    }
    printf("%d ]", numbers[size_numbers-1]);
    printf("\n");
  }
  
  int in_arr(int A, set B[], int B_size) {
      int res = 0;
      int counter;
      for (counter = 0; counter &lt; B_size; counter++) {
          if (A == B[counter]) {
              res = 1;
              break;
          }
      }
      return res;
  }
  
  int arr_in_arr(set smaller[], int smaller_size, set bigger[], int bigger_size) {
      int res = 1;
      int counter;
      for (counter = 0; counter &lt; smaller_size; counter++) {
          if (in_arr(smaller[counter], bigger, bigger_size)) {
              continue;
          }
          else {
              res = 0;
              break;
          }
      }
      return res;
  }
  
  int size_c(set arr1[], int arr1_size, set arr2[], int arr2_size) {
      int i;
      int newsize = 0;
      for (i = 0; i &lt; arr1_size; i++) {
          if (!in_arr(arr1[i], arr2, arr2_size)) {
              newsize++;
          }
      }
      for (i = 0; i &lt; arr2_size; i++) newsize++;
      printf("\nSIZE OF C: %d\n", newsize);
      return newsize;
  }
  
  int Join(set arr1[], int arr1_size, set arr2[], int arr2_size, set arr3[], int arr3_size) {
      int i, j;
      for (i = 0; i &lt; arr1_size; i++) {
          arr3[i] = arr1[i];
      }
      for (i = 0; i &lt; arr2_size; i++) {
          j = i+arr2_size;
          if (!in_arr(arr2[i], arr3, arr3_size)) {
              arr3[j] = arr2[i];
          }
      }
  }
  
  int main () {
      set A[SIZEOF_A] = {c, d, f, a, b, j};
      set B[SIZEOF_B] = {a, b, c, d, e, f};
      int SIZEOF_C = size_c(A, SIZEOF_A, B, SIZEOF_B);
      int counter;
      printf("For the sets,\n");
      printf("A: ");
      dispSet(A, SIZEOF_A);
      printf("B: ");
      dispSet(B, SIZEOF_B);
      printf("C: ");
      set C[SIZEOF_C];
      Join(A, SIZEOF_A, B, SIZEOF_B, C, SIZEOF_C);
      dispSet(C, SIZEOF_C);
      printf("%s\n", (arr_in_arr(A, SIZEOF_A, B, SIZEOF_B) == 1)?"B contains A":"B does not contain A");
  }
  </pre>