-
October 2nd, 2003, 08:09 PM
#1
Sorting a string in Alphabetical order
Can someone help me to a string in Alphabetical order?
-
October 2nd, 2003, 08:39 PM
#2
Ascending sort. Write a compare fxn:
bool compare(char a, char b)
{return a < b;}
Then pass that fxn addess to the STL sort fxn
char* hello = "Hello";
int len = strlen(hello);
sort(hello, hello + len, compare);
I haven't run this thru compiler so check misspells, etc.
Steve
-
October 2nd, 2003, 08:41 PM
#3
P.S. Make sure to include the right header file
#include <algorithm>
using namespace std;
Steve
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|