It is illegal because C++ requires compile-time constant values to be used for the array size when you declare a local array like you did. If you use a dynamic array (with new), then you can give it a variable size.
Since the OP mentioned "pure c", it was not a bad suggestion, it is legal in C, but since this is a C++ forum, it just needs to be noted that it is not (yet) legal in C++ and many compilers won't allow it.