Last active
November 12, 2020 22:26
-
-
Save danielsimao/85b25596962244626a48535f1d4770a2 to your computer and use it in GitHub Desktop.
sortWord <3
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
#include <stdio.h> | |
#include <string.h> | |
#include <ctype.h> | |
#include <stdlib.h> | |
int main(int argc, char **argv, char **envp) | |
{ | |
char words[argc-1][50]; | |
char cmp[50]; | |
int c = 1; | |
int d = 0; | |
//printf("%s\n",getenv("HOSTNAME")); | |
while(argv[c] != '\0') { | |
if(isalpha(argv[c][0])) { | |
strcpy(words[d], argv[c]); | |
d++; | |
} | |
c++; | |
} | |
for(int i = 0; i < d; i++) { | |
for(int j = i + 1; j < d; j++) { | |
if(words[i] == " ") { | |
} | |
if ((strcmp(words[i], words[j]) > 0)) { | |
strcpy(cmp, words[i]); | |
strcpy(words[i], words[j]); | |
strcpy(words[j], cmp); | |
} | |
} | |
} | |
for(int i = 0; i < d ; i++) { | |
printf("%s\n", words[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment