In my university script it's written that we're not allowed to create a local array at runtime with size only known at runtime.
float x[size][2];
That doesn't work because declared arrays can't have runtime sizes. Try a vector:
From: C++ expected constant expression
However this code compiles under Apple LLVM 8.0.0
#include <iostream>
int main(){
int i = 5;
int x;
std::cin >> x;
int array[x];
for(int i = 0; i<x; ++i){
std::cout << array[i] << "\n";
}
}
Edit: And works fine. Prints out garbage as expected.
Reminder: This program is not meant to make any sense.