As GajananH points out, this is a meaningless endevor:
For strlen to work, str must be NULL terminated.
If str is NULL, then:
sprintf(str2, "%.*s", strlen(str), str);
This is just a complication:
sprintf(str2, "%s", str);
Which in itself is more complex:
strcpy(str2, str);
source share