Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #include <cstdio>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <string>
  5. #include <cstdlib>
  6. #include <cstring>
  7. #include <iostream>
  8. #include <vector>
  9.  
  10. using namespace std;
  11.  
  12. int main (int argc, char *argv[])
  13. {
  14. bool flagv = false;
  15. bool flags = false;
  16. bool flagi = false;
  17.  
  18.  
  19. vector<string> filenames;
  20.  
  21. for (int i=1; i<argc; i++)
  22. {
  23. if (strcmp(argv[i],"-v") == 0 )
  24. {
  25. flagv = true;
  26. }
  27. else if (strcmp (argv[i], "-s")==0)
  28. {
  29. flags = true;
  30. }
  31. else if (strcmp (argv[i], "-i")==0)
  32. {
  33. flagi = true;
  34. }
  35. else if (argv[i][0]=='-')
  36. {
  37. cerr << "UNRECOGNIZED FLAG" << endl;
  38. exit (-1);
  39. }
  40. else if (strcmp (argv[i], "")==0)
  41. {
  42. cerr << "EMPTY FILE" << endl;
  43. exit (-1);
  44. }
  45.  
  46. else
  47. {
  48. filenames.push_back(string(argv[i]));
  49. }
  50.  
  51.  
  52. }
  53.  
  54. if(filenames.size()>1)
  55. {
  56. cerr << "TOO MANY FILES" << endl;
  57. exit (-1);
  58. }
  59. if(filenames.size()==0)
  60. {cerr << "FILE NOT FOUND" << endl;
  61. exit (-1);
  62. }
  63.  
  64.  
  65. //filek = filenames[0];
  66.  
  67. {
  68.  
  69. string kmh(filenames[0]);
  70. ifstream kfile ;
  71. kfile.open (kmh);
  72. if (kfile.is_open()==false)
  73. {cerr << kmh << "FILE NOT FOUND" << endl;
  74. exit (-1);
  75. }
  76.  
  77.  
  78.  
  79.  
  80. cout <<flagv << endl << flagi << endl << flags << endl;
  81.  
  82.  
  83. return 0;
  84.  
  85. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement