#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define
BUFFER_LEN
100
/* Length of input buffer */
#define
NUM_P
100
/* maximum number of string */
#define
TRUE
1
#define
FALSE 0
void main()
{
char buffer[BUFFER_LEN];
/*Store for string */
char *pS[NUM_P]= { NULL };
/*Array of string pointers */
char *pTemp = NULL;
/* Pointer to buffer */
int i;
/* Loop counter */
int sorted = FALSE;
int last_string = 0;
/* store the final i */
/*read the string from the keyboard */
printf("\nEnter successive lines,pressing Enter at the end of each line"
".\n Just press Enter to end.\n\n");
while((*gets(buffer) !='\n') && (i<NUM_P))
{
pS[i]=(char *)malloc(strlen(buffer)+1);
if(pS[i]==NULL)
/* Check for no memory allocated */
{
printf("Memory allocation failed.Program terminated.\n");
return;
}
strcpy(pS[i++],buffer);
}
last_string=i;
}