Implement a function that receives an array of integers and its capacity and fills the array with all the values read from the keyboard which are prime numbers, without overflowing the array. The keyboard input might consist of other data (words) that are to be ignored. Return the numbers of elements copied into the array. Also, provide an adequate main().

```
  #include <stdio.h>
    int fills(int arr[], int cap)

    {
    int element, flag=0,i=0,sec;
      while(scanf("%d", &element)==1 && i<cap)
        {
            printf("%d", element);
        sec=element;
       // printf("%d\n", sec);
          for(int j=2;j<sec/2;j++)
          {
              if(sec%j==0)
               flag=1;
          }
          if(flag==0)
          {
              arr[i]=element; 
              i++;
          }
        // printf("%d\n", arr[i-1]); 
         sec=0;

    }
    for(int k=0;k<i;k++)
    {
        printf("%d ", arr[k]);
    } 

}

     int main()
        {
            int arr[4], cap=4;
            fills(arr, cap);
            return 0;
        }

```

This is my code so far, but I can't skip the words or the others elements