You have a problem with
cin >> length;
leaving the line terminator in the buffer.
Input with
cin
is a bit tricky, anyway, a quick fix would be adding
cin.ignore();
immediately before it to eat up the line terminator.
cin >> length;
cin.ignore();
By the way,
Richard gave you the good advice of using
vector<string>
instead of explicitely dynamically allocated array. As matter of fact, in your code you never release the allocated memory.