int len = 8; char *buffer = (char *)malloc(len+1); strncpy(buffer, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", len);