R
R
redSKY2021-06-05 21:26:44
C++ / C#
redSKY, 2021-06-05 21:26:44

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

1 answer(s)
W
Wataru, 2021-06-05
@redSKY

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 question

Ask a Question

731 491 924 answers to any question