Guest User

Untitled

a guest
Jun 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* argv[0] = Execution.. so it acutally is the executable file .. not a paramter so we need to add 1 to the params
  5. argc with a value of 1 = the execution.. so argc 1 = argv[0] */
  6. int main(int argc, char * argv[])
  7. {
  8. char *value;
  9. int i;
  10. int j;
  11. int m;
  12.  
  13. for(i=1; i<argc; i++)
  14. {
  15. value = argv[i];
  16. j = i -1;
  17.  
  18. do
  19. {
  20. argv[j + 1] = argv[j];
  21. j = j-1;
  22. } while(j >= 0 && argv[j] > value);
  23.  
  24. argv[j+1] = value;
  25. }
  26.  
  27. for(m=1; m < argc; m++)
  28. {
  29. printf("%s\n", argv[m]);
  30. }
  31. return 0;
  32. }
Add Comment
Please, Sign In to add comment