The fourth function seems to use the CType bar oneself seems to be very troublesome later to use again,
#include <stdio.h>
#include <string.h>
void Direct_output (char **ptr)
{
int i;
For (i=0;i<10;i++)
puts (ptr[i]);
}
void Asc_output (char **ptr)
{
int i,j;
For (i=0;i<9;i++)
{
For (j=0;j<9-i;j++)
{
if (strcmp (ptr[j],ptr[j+1]) >0)
{
Char *temp;
Temp=ptr[j];
ptr[j]=ptr[j+1];
ptr[j+1]=temp;
}
}
}
direct_output (PTR);
}
void Strlen_output (char **ptr)
{
int i,j;
For (i=0;i<9;i++)
{
For (j=0;j<9-i;j++)
{
if (strlen (Ptr[j]) >strlen (ptr[j+1]))
{
Char *temp;
Temp=ptr[j];
ptr[j]=ptr[j+1];
ptr[j+1]=temp;
}
}
}
direct_output (PTR);
}
void menu ()
{
printf ("Five function You can choose\n");
printf ("1) output initial string list 2) output string in ASCII order \ n");
printf ("3) outputs the string in ascending order of length 4) by the first word in the string, the length of the string \ n");
printf ("5) exit \ n");
}
int main ()
{
int i=0;
int choose;
Char a[10][80];
Char *ptr[10];
printf ("Please enter 10 strings \ n");
While (I<10&&gets (A[i])!=null)
{
Ptr[i]=a[i];
i++;
}
menu ();
scanf ("%d", &choose);
While (choose!=5)
{
switch (choose)
{
Case 1:direct_output (PTR);
Case 2:asc_output (PTR);
Case 3:strlen_output (PTR);
}
menu ();
scanf ("%d", &choose);
}
}
String manipulation procedures