Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <cstring>
  5. bool check(int ac, char* av[]);
  6.  
  7. int main(int argc, char* argv[]) {
  8. check(argc, argv);
  9. getchar();
  10. return 0;
  11. }
  12.  
  13. bool check(int ac, char* av[]) {
  14. if (ac < 3) {
  15. printf("Too few arguments");
  16. return false;
  17. }
  18. else if (ac > 3) {
  19. printf("Too many arugments");
  20. return false;
  21. }
  22. else if (!strcmp(av[1], "numbers.txt") && !strcmp(av[2], "-n")) {
  23. printf("Sorting numbers from numbers.txt");
  24. return true;
  25. }
  26. else if (!strcmp(av[1], "strings.txt") && !strcmp(av[2], "-s")) {
  27. printf("Sorting strings from strings.txt");
  28. return true;
  29. }
  30. return false;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement