#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TRUE 1
#define FALSE 0
#define BUFFER_LEN 240
#define NUM_P 50
void str_sort (char *[], int);
int main ()
{
char *s[NUM_P];
int count;
printf("Enter the number of count:");
scanf("%d",&count);
int i = 0;
printf("enter the first string:");
scanf("%s",&s[0]);
printf("enter the second string:");
scanf("%s",&s[1]);
printf("enter the third string:");
scanf("%s",&s[2]);
printf("enter the fourth string:");
scanf("%s",&s[3]);
printf("enter the fifth string:");
scanf("%s",&s[4]);
str_sort (s, count);
printf("\n the sorted output is: \n \n");
for (i =0; i <count; i ++)
{
printf("%s \n", s[i]);
free(s[i]);
s[i] = NULL;
}
}
void str_sort (char *p[], int n)
{
char *pTemp = NULL;
int i = 0;
int sorted = FALSE;
while (!sorted)
{
sorted = TRUE;
for (i = 0; i <n-1; i++)
if (strcmp(p[i], p[i+1]) > 0)
{
sorted = FALSE;
pTemp = p[i];
p[i] = p[i+1];
p[i+1] = pTemp;
}
}
}
the program stops executing exactly after the 5th scanf statement .. please do help .. thanks :)