You shouldn't dismiss BRP's warning though:

Also, these nested for loops are very inefficient ways to handle character arrays and the only reason it’s not causing trouble is that these are not very big arrays.

It might not be a big a deal in this situation, but realize that every time you have a loop, you're essentially telling the computer to do a certain amount of instructions any number of times. Although each instruction takes constant time, each loop adds n to that time. So, your main takes at least a bit more than O(n^2). I wasn't very good at calculating Big O, but I can at least tell by just looking at it that it's at minimum that much (which it isn't, it's a little more than that). O(n^2) isn't very efficient, with the best you can hope is probably O(log n) and O(n) (and O(1) but chances are, you're not doing anything interesting in that situation).

Edit: 2n + n(2n), so your thing takes O(n^2), I think. Someone who remembers that may be able to provide a more accurate answer if mine is not.