oh and i just tried strncmp for the sake of it. It finds the lexicographically smallest element in my list but i dont exactly want that.
Now comparing a char to another char works (i.e. which ever ones smaller) but it doesn't work on a whole string.
Code:
if (current->next->cityname < start->cityname)
{
printf("%s %s %s", "\nFound a smaller character", start->next->cityname, "\n");
}
and the following doesn't work (it should return a numerical value so i can compare if the string is smaller(i.e. if it comes alphabetically with the one i'm comparing to).
Code:
printf("%d", current->next->cityname);
printf argument mismatch for format d. Expected int got pointer to char
How can i compare if a whole string comes first alphabetically?
i.e.
Denmark 28.80 17.60
Bahamas 5.60 79.12
Canada 55.30 49.90
Antarctica 22.22 11.11
Antarctica is the smallest in this case.
and just an example where i was comparing the current element to the next
Code:
char b = 'B';
char a = 'A';
if (b > a)
{
printf("It's greater in value, therefore it should be swapped.");
}