cws.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* This file creates the file white-space.txt */
  2. #include <stdio.h>
  3. #include <argp.h>
  4. enum boolean { NO, YES };
  5. enum boolean bool = NO;
  6. const char * argp_program_version = "0.1";
  7. /* mail bug reports to */
  8. const char * argp_program_bug_address = "jbranso@fastmail.com";
  9. static const struct argp_option options [] =
  10. {
  11. //{"", 'j', "ARG", OPTION_ARG_OPTIONAL, "Print a funny joke" },
  12. { 0 }
  13. };
  14. error_t argp_parser (int opt, char *arg, struct argp_state *state) {
  15. extern enum boolean bool;
  16. switch (opt)
  17. {
  18. // if this parser function is called on an option that it doesn't recognize, then don't do anything.
  19. default:
  20. return ARGP_ERR_UNKNOWN;
  21. /* case 'j': */
  22. /* { */
  23. /* bool = YES; */
  24. /* break; */
  25. /* } */
  26. }
  27. return 0;
  28. }
  29. struct argp argp =
  30. { options, argp_parser, 0, "creates a data file white-space.txt" };
  31. int main (int argc, char **argv) {
  32. argp_parse (&argp, argc, argv, 0, 0, 0);
  33. FILE * file = fopen("white-space.txt", "w");
  34. fputs ("This is some serious \n", file);
  35. fputs ("white space\n", file);
  36. fputs ("bro \n", file);
  37. fputs ("It totally is.\n", file);
  38. fputs ("Why did the duck cross the road? \n", file);
  39. fputs ("Well that's annoying.\n", file);
  40. fclose (file);
  41. return 0;
  42. }