Answer the question
In order to leave comments, you need to log in
How to set up the C++ IDE?
Good evening. I solve problems on stepik. It’s more convenient for me to solve them in Visual Studio 2019 and then copy them to stepik. To solve the problem, I create a dynamic array. The visual requires you to create a constant n in advance, otherwise the code will not run in Visual Studio 2019.
BUT this is not required in stepik or online compilers. How can I change compiler settings?
#include <iostream>
using namespace std;
void main() {
int n; // если n не определена зарание ,вылетает ошибка.
cin >> n;
int a[n];
}
Answer the question
In order to leave comments, you need to log in
This is not how you create a dynamic array in C++. This is VLA and is not a standard. VS does not seem to support it at all, unlike gcc, which compiles this code, although it does not have to. Apparently, on the servers is g ++.
None of the settings will help you.
You need to allocate a dynamic array via new[] or better use std::vector.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question