In a book (C++ Primer) I found that "A nonconst variable or a const variable whose value is not known until run time, cannot be used to specify the dimension of an array". Then I made 2 programs to test it:
`
#include <iostream>
using namespace std;
//PROGRAM 1
int main() {
const int j;
int k[j];
return 0;
}
program one was bound to fail as j hasn't been initialized despite being constant.
`
int main() //PROGRAM 2
{
int k;
cin>>k;
int p[k];
return 0;
}
This works fine but it contradicts the book. Please tell me if that book statement was for some version other than C99.