Your use of std::string's operator[] hides a potential problem, you could exceed the boundaries of the string if the string's size is less than 56 characters.
Getting the first character of an empty string using operator[] returns a reference to the null character that follows the last character in the string. You got lucky you didn't end up with undefined behavior or a thrown exception.
If you used std::string's at() member function instead you'd have to wrap line 13 in a try/catch block.
Duthomhas wrote:
What if the argument string has fewer than seven rows?
The excess rows (and columns) would be filled with the null character ('\0'). So the output would have some blank rows. (Visual Studio 2019)