Hi,
I was working on sorting 2 dimension arrays in ascending order and need a little help.
Here is my code:
Code:
#include <stdio.h>
void bubbleSort(int [][]);
void swap(int *,int *);
int main()
{
int i;
char list[5][9] = {"tulip","marigold","petunia","rose","daisy"};
for(i=0;i<5;i++) {
printf("\n%10s", *(list + i) );
}
printf("\n\n");
return 0;
}
void bubbleSort(int list[][]))
{
int current,walker;
for(current=0;current<MAX;current++){
for(walker=MAX-1;walker > current;walker--) {
if (list[walker] < list[walker-1]) {
swap(&list[walker],&list[walker-1]); //swap
}
}
}
}
void swap(int *val1,int *val2)
{
int temp;
temp = *val1;
*val1 = *val2;
*val2 = temp;
}
can someone please help me with that? I am also suspecting the use of strcmp() and and strcpy() to copy one string to another, but now sure how.
Thanks