0

I have problems. The expression must have a constant value line 17. VS E0028. I need to change array but it says that i must use constant ;( I am beginner in coding so i need your help

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    setlocale(LC_ALL, "ru");
    int a = 1;
    int b, c;
    cin >> a;
    int i = 0;
    bool happy;
    int r = 1;
    for (r;r < a; r++)
    {
        int arr[r]; //error [r] ;(
        for (i; i < 100000000; i + 5)
        {
            happy = false;
            c = pow(i, 2);
            if (c % 100 == 25)
            {
                happy = true;
                arr[r] = i;
            }
        }
    }

    if (happy = true)
    {
        cout << i << endl;
    }

    return 0;

}
  • Note that we can't see line numbers. Put a comment (`//`) next to the line that gives the error. – cigien Feb 09 '21 at 06:06
  • Thanks for adding the comment. The answer to your question, as indicated by the duplicate, is that this is not allowed. Use a `std::vector` instead. – cigien Feb 09 '21 at 06:45

0 Answers0