hi everyone!!!
I am trying to write a code for list of names to be sorted in alphabetical order.
can anybody please tell me what I am doing wrong.
and one more thing , is it possible to bubble sort a names in unspecified number of entries? and if it is possible how will the program know where is the end of the list?
I was also wondering if I could do bubble sort with strings?
many thanks in advance.
here is what I have got so far
include <iostream>
using namespace std;
int main()
{
char name[3][30];
int i, j;
for(i=0;i<=2;i++)
{
cout << "Please enter name: ";
cin >> name[i];
}
for(i=0;i<=1;i++)
{
for(j=i+1;j<=2;j++)
{
char temp;// problems with this one , i have changed int to char
if(name[i] > name[j])
{
temp = name[i];// I have some problems here
name[i] = name[j];
name[j] = temp;
}
}
}
for(i=0;i<=2;i++)
{
cout << endl << name[i] << endl;
}
cin.ignore();
cin.get();
//system("pause");
}