Last active
November 13, 2016 16:19
-
-
Save Sreyas-Sreelal/42f6f9e1c50f9696530eeaac2c82222f to your computer and use it in GitHub Desktop.
Sorts the strings in alphabetic order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1) | |
/*Alphabet sorter by Sreyas*/ | |
alpha(str[MAX_NAMES][MAX_PLAYER_NAME]) //MAX_NAME - total number of strings in that matrix | |
{ | |
new i, j,t[24]; | |
for(i=1; i<MAX_NAMES; i++) | |
{ | |
for(j=1; j<MAX_NAMES; j++) | |
{ | |
if(strcmp(str[j-1], str[j])>0) | |
{ | |
strcpy(t, str[j-1]); | |
strcpy(str[j-1], str[j]); | |
strcpy(str[j], t); | |
} | |
} | |
} | |
printf("Names in alphabetical order "); | |
for(i=0; i<MAX_NAMES; i++) | |
{ | |
printf("%s",str[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment