=\ I was gunna post a problem I'm having in my programming class, we had to make a phone book with addresses numbers and 3 part names blah all easy crap, you can input and delete entries etc. but when displaying the phone book you had to have it sorted in ABC order.. I tried first to use a bubble sort, thinking it would just do it by the ASCII values of the letters, not thinking that it would actually use pointers. any ways cracked open crappy old c++ for you++ any who here is my modified bubble sort for sorting strings
struct PHONE
{
char name[20], mi[20], last[20], number[11];
}
phone[20];
void bubble_sort(PHONE array[], int arraylength)
{
int i,j, flag=1;
PHONE temp;
for(i=0;(i<=arraylength-1)&&flag;i++)
{
flag=0;
for(j=1;j<(arraylength);j++)
{
if(strcmpi(array[j+1].last,array[j].last) <0)
{
temp=array[j+1];
array[j+1]=array[j];
array[j]=temp;
flag=1;
}
}
}
}
struct PHONE
{
char name[20], mi[20], last[20], number[11];
}
phone[20];
void bubble_sort(PHONE array[], int arraylength)
{
int i,j, flag=1;
PHONE temp;
for(i=0;(i<=arraylength-1)&&flag;i++)
{
flag=0;
for(j=1;j<(arraylength);j++)
{
if(strcmpi(array[j+1].last,array[j].last)
{
temp=array[j+1];
array[j+1]=array[j];
array[j]=temp;
flag=1;
}
}
}
}
