But you have a bit of nonstandard C++ you should avoid:
You cannot create array of size not known at the compile time. Some compilers allows you to use VLA extension, but you should turn nonstandard features off and not use them. Because they are nonstandard and by definition nit guaranteed to work everywhere. Use vector or explicitly create a dynamic array through new.