sorting characters

Malfunction

Junior Contributor
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 wasn't a problem but sorting by names is.
if (courseA.Name > courseA.Name) ....
Is not sorting correctly.
 
You'll need to use strcmp to compare the two strings or don't declare your "string" as char*, use an actual string class.

-Nerseus
 
Back
Top