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