Well, you need to check the return value of fgets. If it returns 0 (NULL), then you should break out of the do-while block.
strncpy is a standard function, but you're using it incorrectly. It pads the rest of dest with '\0' when it reaches the end of the src string, until it's written the number of bytes given to it as a size. Since you give it a size greater than the number of bytes you allocate to str_ptr[count], it will overflow dest. I suggest you read up on how to use it: http://pubs.opengroup.org/onlinepubs/7908799/xsh/strncpy.html
Anyway, since you allocate enough space for the string, then you may as well just strcpy or memcpy buffer to str_ptr[count].
The next problem you have is that you don't free the memory you allocate through malloc. You can fix this by just calling free after you print the string to stdout, or at a later time.
Another problem, is that you don't check check whether malloc passed a null pointer back to you or not. If it did, then you strcpy it, you'll have the same problem that you have with using strncpy. (You'll be trying to access memory that you're not allowed to.)
Here's a copy of the changes I've made:
#include
#include
#include
int main(void)
{
char *strptr[4];
char buffer[80];
size_t count;
size_t i;
for (count = 0; count < sizeof strptr / sizeof strptr[0]; count++) {
size_t size;
printf("Enter a line: ");
fflush(stdout);
if (!fgets(buffer, sizeof buffer, stdin))
break;
size = strlen(buffer) + 1;
strptr[count] = malloc(size * sizeof *strptr[count]);
if (!strptr[count]) {
fprintf(stderr, "Unable to allocate memory\n");
return EXIT_FAILURE;
}
strcpy(strptr[count], buffer);
printf("You just typed %s. Its length is %lu.\n",
strptr[count], (unsigned long) size);
}
for (i = 0; i < count; i++)
free(strptr[i]);
return 0;
}