The problem is not an IMAP problem, or a c-client problem. It is a problem in your C code. It would be better if you ask such questions in a C programming forum.
The following clues may help you: The reason why you got a "Bad address" error is that you tried to write into a write-protected area of memory. The read() call reads from the network, but writes into memory. One of the arguments to the read() call in your program is incorrect, and is the cause of the attempt to write into a write-protected area of memory. C does not dynamically allocate space for strings ala LISP or BASIC. In C, you must do so yourself. Also, the concept of "pointers" is very important in C.
