By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,846 Members | 1,231 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,846 IT Pros & Developers. It's quick & easy.

Sort string arrays using bubble sort

P: 25
I am doing a program for Intro to Computer Programming where we take an array of strings and we must sort them alphabetically. we are supposed to use a bubble sort, but i know the code if meant for integers. How do i get a bubble sort to put names in alphabetical order?
Apr 6 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,652
Use the strcmp() method. It accepts two string arguments and returns -1 if the first is less than the second, 1 if the first is greater than the second, and 0 if the strings are the same. Use this to compare the strings rather than > or <.
Apr 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.