Hey there,
I'm writing a little program in C, and have an array of structures.
I was thinking of using the ASCII number of the first character of each string and doing an, if larger do such 'n' such, if smaller do such 'n' such.
At this point i became unstuck becasue i can't figure out a method to get the ASCII of the 1st character in the string! If anyone has an idea (and im sure you do!), or any other recommendations as to how to go about sorting my array of structures via a string held within them, it'd be great to hear.
Cheers
I'm writing a little program in C, and have an array of structures.
Id like to sort them alphabetically by using one element in each structure, (sname for example) but am not sure where to begin..typedef
struct
{
char fname[20];
char sname[20];
char address[40];
} book;
book record[200];
I was thinking of using the ASCII number of the first character of each string and doing an, if larger do such 'n' such, if smaller do such 'n' such.
At this point i became unstuck becasue i can't figure out a method to get the ASCII of the 1st character in the string! If anyone has an idea (and im sure you do!), or any other recommendations as to how to go about sorting my array of structures via a string held within them, it'd be great to hear.
Cheers