title: C: Why doesn't this code work?
body: <p>Need help with this code it should return <code>c[]</code> with the number's of <code>a[] % b[] = 0</code> but it doesn't work.</p>
  
  <pre><code>#define _CRT_SECURE_NO_WARNINGS
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int *divide(int a[], int a_size, int b[], int b_size)
  {
      int i = 0, j = 0, k = 0, counter = 0, *c;
      c = (int*)malloc(b_size * sizeof(int));
  
      for (i = 0; i &lt; b_size; i++)
      {
          for (j = 0; j &lt; a_size; j++)
          {
              if (a[j] % b[i] == 0)
                  counter++;
          }
  
          c[k] = counter;
          k++;
          counter = 0;
      }
  
      for (int t = 0; t &lt; b_size; t++)
      {
          printf("%d ", c[t]);
      }
      printf("\n");
  }
  
  main ()
  {
      int *a, *b, a_size, b_size;
  
      printf("Enter size of a:\n");
      scanf ("%d", &amp;a_size);
      a = (int*)malloc(a_size * sizeof(int));
  
      printf("\nEnter size of b:\n");
      scanf("%d", &amp;b_size);
      b = (int*)malloc(b_size * sizeof(int));
  
      printf("\nEnter elements of a:\n");
      for (int i = 0; i &lt; a_size; i++)
      {
          scanf("%d", &amp;a[i]);
      }
  
  
      printf("\nEnter elements of b:\n");
      for (int j = 0; j &lt; b_size; j++)
      {
          scanf("%d", &amp;b[j]);
      }
  
  
      divide(&amp;a, a_size, &amp;b, b_size);
  }
  </code></pre>