Hello,

I am new to C++ and have so interest in this programing....im trying to Sort String Values in Ascending Order by declaring arrays...

Actually i want to get input form the user of five words (Cat, Bat, Arm, Dog, Man) and then want to sort them in ascending order like (Arm, Bat, Cat, Dog, Man) and then want to show it on output.

i tried code but i am getting error can you tell me what is the problem in array string and can you please write and justify the complete this code so that i get output with no errors...thanks

here is code:

#include <iostream>
#include <string>

using namespace std;
int main(){

char s[5];
char array[5][80];

cout<<"Enter 5 words followed each by <enter>"<<endl;

for(int i=0; i<5; i++)
{
cin.getline(s[i],20);
}

for(int j=0; j<5; j++)
{

cout << s[j]<<endl;
}


return 0;
}





many thanks.

Paul.