Friday, 23 August 2013

Logic challenge: sorting arrays alphabetically in C

Logic challenge: sorting arrays alphabetically in C

I'm new to programming, currently learning C. I've been working at this
problem for a week now, and I just can't seem to get the logic straight.
This is straight from the book I'm using:
Build a program that uses an array of strings to store the following names:
- "Florida" - "Oregon" - "Califoria" - "Georgia"
Using the preceding array of strings, write your own sort() function to
display each state's name in alphabetical order using the strcmp()
function.
Should I do nested for loops, like strcmp(string[x], string[y])...? I've
hacked and hacked away. I just can't wrap my head around the algorithm
required to solve this even somewhat efficiently. Help MUCH appreciated!!!

No comments:

Post a Comment