•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,565 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,581 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 1558 | Replies: 5
![]() |
•
•
Join Date: Oct 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I want to write a function to perform lexicographical sorting using a simple bubble sort technique. So far I've got the basic code running, but something is not right. I can tell the algorithm is wrong but cannot fix it, please help.
I've tried not to use the third inner loop, but then it will just perform the first letter comparison...And yes, let me stress that strcmp or strncmp should not be used...
Thank you in advance.
I want to write a function to perform lexicographical sorting using a simple bubble sort technique. So far I've got the basic code running, but something is not right. I can tell the algorithm is wrong but cannot fix it, please help.
int bubble_sort(char **words, int num_word)
{
int x, y, z;
char *temp;
for (x = 0; x < num_word; x++)
{
for (y = 0; y < (num_word-1); y++)
{
for (z = 0; z < (WORD_SIZE+1); z++)
{
if (words[y][z] < words[y+1][z])
{
temp = words[y+1];
words[y+1] = words[y];
words[y] = temp;
break;
}
else
{
continue;
}
}
}
}
return 0;
}I've tried not to use the third inner loop, but then it will just perform the first letter comparison...And yes, let me stress that strcmp or strncmp should not be used...
Thank you in advance.
Re: Sort strings in lexicographical order but not to use built-in string functions
#2
Oct 21st, 2007
Re: Sort strings in lexicographical order but not to use built-in string functions
#3
Oct 21st, 2007
•
•
Join Date: Oct 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Re: Sort strings in lexicographical order but not to use built-in string functions
#4
Oct 21st, 2007
Re: Sort strings in lexicographical order but not to use built-in string functions
#5
Oct 21st, 2007
•
•
Join Date: Oct 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Re: Sort strings in lexicographical order but not to use built-in string functions
#6
Oct 21st, 2007
Hi iamthwee,
However, I solved the problem myself: http://www.daniweb.com/forums/post455234.html
The reason why I registered both forums is because I want to get as many thoughts as possible.
Just want to say, I'm a little bit "more" different than other "chumps", maybe not enough to let you Senior Posters (or so) to realize. After all, I know I am a noob to programming, but I'm eager to learn, that's enough for me.
Thank you for your opinion anyways.
Woozy
However, I solved the problem myself: http://www.daniweb.com/forums/post455234.html
The reason why I registered both forums is because I want to get as many thoughts as possible.
Just want to say, I'm a little bit "more" different than other "chumps", maybe not enough to let you Senior Posters (or so) to realize. After all, I know I am a noob to programming, but I'm eager to learn, that's enough for me.
Thank you for your opinion anyways.
Woozy
Last edited by woozy : Oct 21st, 2007 at 5:43 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Differences Between Java and C/C++ (C++)
- Open In New Window Php (PHP)
- Creating a Basic String Database (C++)
- Recursion II (C++)
- urgent help needed (Java)
- sort string in file txt (C++)
- Array troubles? (C++)
Other Threads in the C Forum
- Previous Thread: Reading from a file and counting how many time each letter occurs.
- Next Thread: pointer notation



Linear Mode