this is not C89

strncpy(string,buffer,strlen(buffer));
what about nul-terminator?