Quote Originally Posted by cas View Post
The obvious candidate in this piece of code is the index into codetable; if it's out of range you could get a segfault. I suppose you had to comment that out, though, when you commented out the codetable declaration.

When you get a segfault, your first step should be to use a debugger to pinpoint where the problem is, if not why it's occurring. Two good, free debuggers are Valgrind and gdb. They approach debugging in different manners, and each has its uses, but I tend to find Valgrind more useful.

Gdb should tell you where the segfault is happening. Valgrind might be able to tell you where the actual problem is: where a segfault occurs is not necessarily where your bug is. Either way, learning how a debugger works should be one of the first things you do when leaning how to program. After all, creating bugs is also one of the first things you do!
Unfortunately the server I am working on does not have valgrind