c++ beginner here, recently switched from Codeblocks to Visual studio and I have encountered a problem. Usually, when I was defining in small projects the size of an array, I would so through a variable n:
#include <iostream>
int main()
{
int n;
std::cout << "Size of array?" << std::endl;
std::cin >> n;
int a[n];
}
This method of allocating size seems to work just fine with the first choice, but when I compile in Visual studio it says: E0028 expression must have a constant value. I get it that a variable can change in value, but why does it work in Codeblocks?