is there any function that helps to sort an array of strings alphabeticly
i need to sort an array alphabeticly which contains names of students
thx 4 yr help
matika :cool:
matika
0
Newbie Poster
Recommended Answers
Jump to Postvoid qsort ( void * base, size_t num, size_t width, int (*fncompare)(const void *, const void *) );
Sort using quicksort algorith.
This function uses an implementation of the quicksort algorithm to sort the num elements of an array pointed by base, each element has the specified width in bytes.
…
Jump to Postwait... are you trying to list names of students alphabetically or are you trying to change the characters in each students name around into alphabetical order?
Jump to Posthey,I will give you a direction.
You will first have to make a funtion which will compare 2 strings and say which one is greater by comparing the individual chars and returning when it hit's a char which is no equal to the other, like sad sam, (in this …
Jump to PostC or C++?
The C solution is qsort, and the only difference from what was already shown is the comparison function you write.
In C++ there is a std::sort.
#include <iostream> #include <vector> #include <algorithm> typedef std::vector<std::string>::iterator iter; typedef std::vector<std::string>::const_iterator citer; void Show(std::vector<std::string> &alist, const …
All 15 Replies
meabed
37
Junior Poster
Team Colleague
matika
0
Newbie Poster
kalachylde
0
Newbie Poster
FireNet
64
Posting Whiz in Training
matika
0
Newbie Poster
matika
0
Newbie Poster
Dave Sinkula
2,398
long time no c
Team Colleague
FireNet
64
Posting Whiz in Training
Dave Sinkula
2,398
long time no c
Team Colleague
FireNet
64
Posting Whiz in Training
dooda man
-3
Newbie Poster
FireNet
commented:
making false answers
-3
FireNet
64
Posting Whiz in Training
matika
0
Newbie Poster
Fili
0
Light Poster
sachin_mnnit
0
Newbie Poster
jonsca
commented:
4 years too late
+0
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.