#include <stdio.h>
#include <string.h>
#define strLen 20
/*************************************************************
* Using bubble sort to sort an array of strings.
* We included the <string.h> headr file and enables us to use
* strings manipulation tools. We used the strcmp tool to
* compare between two strings in order to determine their
* lexicographical order. We also used the strcpy tool.
*************************************************************/
void main(){
char arr[][strLen]={"nechama", "sars", "shlomi", "asnat", "zion", "menachem"};
char tmp[strLen];
int i, j, arrSize;
for (i=0; i< arrSize; i++) printf("%s \n", arr[i]);
printf("The array has %d elements\n", ( arrSize = sizeof(arr)/strLen));
for ( i=0; i< arrSize; i++)
for (j=1; j < arrSize; j++)
if (strcmp(arr[j-1], arr[j]) > 0){
strcpy(tmp, arr[j-1]);
strcpy(arr[j-1],arr[j] );
strcpy(arr[j], tmp);
}
for (i=0; i< arrSize; i++) printf("%s \n", arr[i]);
}