Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main (int argc, char *argv[])
  5. {
  6. char str1[10], str2[10], str3[10], str4[10];
  7.  
  8. strcpy(str1, "--version");
  9. strcpy(str2, "--usage");
  10. strcpy(str3, "--hexdump");
  11.  
  12. if (argc > 1)
  13. {
  14. strcpy(str4, argv[1]);
  15. }
  16.  
  17. if (((strcmp(str1, str4)) == 0) && (argc == 2))
  18. {
  19. fprintf(stdout, "1.0\n");
  20. return 0;
  21. }
  22. if (((strcmp(str2, str4)) == 0) && (argc == 2))
  23. {
  24. fprintf(stdout, "Usage:\n./pnmdump.exe --version\n./pnmdump.exe --usage\n./pnmdump.exe --hexdump [FILE]\n");
  25. return 0;
  26. }
  27. if (((strcmp(str3, str4)) == 0) && (argc == 3))
  28. {
  29. fprintf(stdout, "print the file (1.0)\n");
  30. return 0;
  31. }
  32. else
  33. {
  34. fprintf(stderr, "pnmdump: bad arguments\nUsage:\n./pnmdump.exe --version\n./pnmdump.exe --usage\n./pnmdump.exe --hexdump [FILE]\n");
  35. return 1;
  36. }
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement