fork download
  1. #include <errno.h>
  2. #include <getopt.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. void print_help(void)
  7. {
  8. printf("Help");
  9. printf("> cast -d (deletes file)");
  10. printf("> cast -r (renames file)");
  11. printf("> cast -c (create new file)");
  12. printf("> cast -s (scans for file in directory)");
  13. printf("________________________________________");
  14. printf("Find an error or a bug? please submit it in the issues section on github\n");
  15. }
  16.  
  17. int main(int argc, char **argv)
  18. {
  19. int option_val = 0;
  20. int opt_delete = 0;
  21. int opt_help = 0;
  22.  
  23. while ((option_val = getopt(argc, argv, "dh")) != -1) {
  24. switch (option_val) {
  25. case 'd':
  26. opt_delete = 1;
  27. break;
  28. case 'h':
  29. opt_help = 1;
  30. break;
  31. default: /* '?' */
  32. print_help();
  33. }
  34. }
  35.  
  36. if (opt_delete) {
  37. printf("Delete file\n");
  38. } else if (opt_help) {
  39. print_help();
  40. } else {
  41. print_help();
  42. }
  43. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Help> cast -d (deletes file)> cast -r (renames file)> cast -c (create new file)> cast -s (scans for file in directory)________________________________________Find an error or a bug? please submit it in the issues section on github