sorting characters

Malfunction

Well-known member
Joined
Dec 8, 2003
Messages
203
Location
Berlin, Germany
I have a struct

struct list
{
int No;
char *Name;
};

and the "instance"

struct list courseA[5];

initialised with five names and numbers.

I needed two functions to sort courseA by names and number. The latter wasnt a problem but sorting by names is.
if (courseA.Name > courseA.Name) ....
Is not sorting correctly.
 
Youll need to use strcmp to compare the two strings or dont declare your "string" as char*, use an actual string class.

-Nerseus
 
Back
Top