#include<iostream.h>
int main(int argc, char* argv[])
{
char *str[10];
char *g;
for(int j=0; j<10; j++)
{
str[j]= new char[255];
cin>>str[j];
}
for(int k=9;k>=0;k--)
for(int i=0; i<k; i++)
{
if(*str[i]>*str[i+1])
{
g=str[i];
str[i]=str[i+1];
str[i+1]=g;
}
}
cout << "----" <<endl;
for(int y=0; y<10; y++)
{
cout<<str[y]<< endl;
delete[] str[y];
}
return 0;
}
Note:
1. char *str[10] is an array of 10 char pointers
2. so you need to allocate memory for these pointer thus
str[j]= new char[255];
3. for g to refer to str[i], g must also be a pointer
char *g
4. we need clean up memory before exit thus
delete[] str[y]