Well, compliments of myself and quazah's valuable insight,
here's a solution:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINES 5
int AddString(char*** a_string, const char* text, int* size);
int main()
{
char **lines=NULL;
int n=0, i;
char buffer[100];
puts("Enter one line at time enter a blank when done.");
while((n!=MAXLINES) && (fgets(buffer,99,stdin) != NULL) && (buffer[0] !='\0') )
AddString(&lines,buffer,&n);
for(i=0;i<n;i++)
{
printf("%s",lines[i]);
free(lines[i]);
}
free(lines);
return 0;
}
int AddString(char*** a_string, const char* text, int* size)
{
int i=0,j=0;
char** newlist;
if( (newlist = malloc(sizeof(char*)*(*size+1)))==NULL);
for(i=0; i < *size;i++)
newlist[i] = (*a_string)[i];
free(*a_string);
if( (newlist[i] = malloc(strlen(text)+1)) == NULL )return 1;
memcpy(newlist[i],text,strlen(text)+1);
*a_string = newlist;
*size += 1;
return 0;
}