I was trying to solve my first problem on linked list as I had just learned the concept. I kept getting a Runtime Error - SIGSEGV (I understand that my program is trying to access some memory address that it is not supposed to).
int n;
cin>>n;
int v[n];
for(int i=0;i<n;i++)
{
cout<<"\n "<<i<<endl;
// To be removed, helps check till where the loop ran;
cin>>v[i];
cout<<v[i];
}
Every time the loop would run till the second last element and after that, in the last loop, it would give the error.
I know this a very basic question but can someone help me, I have been stuck on it for very long now.
Question Link