I'm getting errors related to the array size, the errors are:
line 19: expression did not evaluate to a constant <br/>
line 31: array type 'int[*n]' is not assignable <br/>
line 34: array type 'int[*n]' is not assignable <br/>
#include "stdafx.h"
#include "iostream"
int main()
{
using namespace std;
int x=0;
int cst=0;
int cstF=0;
int rst=0;
int n=1;
cout << "insira o numero de consultas" << endl;
cin >> n;
int hora[2 * n];
for (x = 0; x == 2 * n - 2; x += 2)
{
cout << "insira o horario de inicio" << endl;
cin >> cst;
if (hora[x - 2] < cst && hora[x - 1] > cst)
rst = rst;
else
{
rst = rst + 1;
}
hora[x] = cst;
cout << "insira o horario de termino" << endl;
cin >> cstF;
hora[x + 1] = cstF;
}
cout << "o numero de consultas possiveis eh: " << rst << endl;
return 0;
}
I'd really appreciate some light on why I'm getting errors.