This is the code I got, which works, but crashes randomly: http://pastebin.com/yyvUSaTQ
(sorry about the external link, it was too big to paste here)
So yeah, I was basically wondering if anyone could spot any obvious problems or suggest a completly new way of making a text editor in a program. (that uses SDL)