Ошибка сегментации (ядро сброшено) при попытке найти подмассив - PullRequest
0 голосов
/ 24 июня 2019

Ошибка сегментации (ядро сброшено)

Я пытался сделать указатели начала и конца. Размещение переменных в разных местах.

int find_subarray(int a[], int size_a, int b[], int size_b, int* start, int* end);

int main()
{
  int size_a;
  int size_b;
  int start = 0;
  int end = 0;
  /*Enters length of first array*/
  printf("Enter the length of the first array: ");
  scanf("%d", &size_a);

  /*sets first array to size_a */
  int a[size_a];

  int i;
  printf("Enter the elements of the first array: ");
  for(i = 0; i < size_a; i++)
  {
    scanf("%d", &a[i]);
  }

  /*Enters length of second array*/
  printf("Enter the length of the second array: ");
  scanf("%d", &size_b);

  /*sets second array to size_b */
  int b[size_b];

  printf("Enter the elements of the second array: ");
  for(i = 0; i < size_b; i++)
  {
    scanf("%d", &b[i]);
  }


  find_subarray(a, size_a, b, size_b, start, end);

  if(end != size_b)
  {
    printf("Output: The secound array is not a subarray of the first array.\n");
  }else
  {
    end += start;
    printf("Output: The second array is a subarray of the first array.\n");
    printf("The subarray starts at index %d and ends at index %d.\n", start, end);
  }

    return 0;
}

int find_subarray(int a[], int size_a, int b[], int size_b, int *start, int *end)

выдает предупреждение: передача аргумента 6 из 'find_subarray' делает указатель из целого числа без приведения и если запустить, он делает первую часть до последней опубликованной строки. Затем происходит ошибка сегментации (ядро сброшено)

...