Hey guys,
First time poster here.:)
Just started my C++ career and am working with pointers/arrays at them moment. I was wondering why I cannot take a user input ('n') to create the size of the array "y". Can anyone show me why this syntax is wrong? Thanks for the help.
#include <iostream>
using namespace std;
int main()
{
int x[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n;
cin >> n;
int y[n];
for (int i = 0; i < n; i++)
cout << (y[i] = x[i]) << " " ;
cout<< endl;
return 0;
}