I am relatively new to C++ and switched operating devices from windows to mac. I did encounter a lot of problems while installing the same and is also the reason why I am asking this question. Previously the following code (Please note that the same libraries are initialized and the same code is written outside the main block.)
on Windows:
int main(){
int n = 5;
int array[n] = {7, 4, 2, 8, 1} ;
insertionSort(array, n);
}
works perfectly well for me while on mac (apple silicon) i get the following error:
stdc.cpp:6:13: error: variable-sized object may not be initialized
int arr[n] = {7, 4, 2, 8, 1};
Is this an OS thing which restricts me from initializing a variable length to an array and assigning a value or did I install it incorrectly? Please note that I used VS Code on both.