'Compiles in CMD line fine with GCC but Visual studios "expression must have constant value" [duplicate]

As title states the code compiles and outputs in the GCC just fine, I want to step by step follow the code in visual so I can make sure I fully understand how things are working but it throws "expression must have a constant value" for the int even[len_sub_arr]; int

odd[len_sub_arr]; lines.

   #include <stdio.h>

void print_arr(int len, int arr[], char name[]) {
  //print number array
  printf("Listing of %s below: \n", name);
  for(int i=0; i < len; i++) {
    printf("%s[%d] = %d\n", name, i, arr[i]);
  }
  printf("\n");
}

int main(void) {
  //initialize and print lengths
  int arr_nums[] = {12, 75, 23, 43, 94, 82, 37, 6, 70, 59};
  int len_arr = sizeof(arr_nums) / sizeof(int);
  printf("Length of arr_nums is %d\n", len_arr);

  int len_sub_arr = len_arr / 2;
  **int even[len_sub_arr];
  int odd[len_sub_arr];**
  printf("Therefore, the length of the even and odd arrays will be = %d\n\n", len_sub_arr);

  //print original array
  print_arr(len_arr, arr_nums, "arr_nums");

  //keep track of even and odd indices
  int even_idx = 0;
  int odd_idx = 0;
  //sort original data into even and odd arrays
  for(int i=0; i< len_arr; i++) {
    if(arr_nums[i] % 2 == 0) {
      even[even_idx] = arr_nums[i];
      even_idx++;
    }
    else {
      odd[odd_idx] = arr_nums[i];
      odd_idx++;
    }
  }

  //print even and odd arrays
  print_arr(len_sub_arr, even, "even");
  print_arr(len_sub_arr, odd, "odd");

  return 0;
}

I keep running into the discrepancies between GCC and visual studios seems to cause me nothing but problems when I feel like something is about to click for me... should I as a beginner continue using the visual studios suite or is there something else you all would recommend to me to use?

c


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source