This exception is thrown by new operator when it is failing to allocate memory. Use nothrow construct and check the pointer if it is null to get rid of the exception.
I don't really understand that literature. Is the nothrow a kind of suppressing the bad_alloc? If so I'm not supposed to do that, and I'd like to learn how to dynamically allocate without having such an issue. It shouldn't be a memory problem, because the arrays I'm using are only 25 characters. Even so, if running out of memory is the problem, if someone tried my program on a computer with more available, the problem wouldn't arise, would it?
It looks like you don't set a value for rows or cols, so they will be whatever garbage value is in memory - garbage values that mean you're asking for a huge amount of memory.
They're set by reading in the text file. rows and cols are the first two items in the file
Which is done after using them to allocate memory. If you want to use rows and cols to calculate the amount of memory to allocate, you have to set their values before you use them to calculate the amount of memory.