Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <fstream>
- #include <sstream>
- #include <string>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <vector>
- using namespace std;
- int main (int argc, char *argv[])
- {
- bool flagv = false;
- bool flags = false;
- bool flagi = false;
- vector<string> filenames;
- for (int i=1; i<argc; i++)
- {
- if (strcmp(argv[i],"-v") == 0 )
- {
- flagv = true;
- }
- else if (strcmp (argv[i], "-s")==0)
- {
- flags = true;
- }
- else if (strcmp (argv[i], "-i")==0)
- {
- flagi = true;
- }
- else if (argv[i][0]=='-')
- {
- cerr << "UNRECOGNIZED FLAG" << endl;
- exit (-1);
- }
- else if (strcmp (argv[i], "")==0)
- {
- cerr << "EMPTY FILE" << endl;
- exit (-1);
- }
- else
- {
- filenames.push_back(string(argv[i]));
- }
- }
- if(filenames.size()>1)
- {
- cerr << "TOO MANY FILES" << endl;
- exit (-1);
- }
- if(filenames.size()==0)
- {cerr << "FILE NOT FOUND" << endl;
- exit (-1);
- }
- //filek = filenames[0];
- {
- string kmh(filenames[0]);
- ifstream kfile ;
- kfile.open (kmh);
- if (kfile.is_open()==false)
- {cerr << kmh << "FILE NOT FOUND" << endl;
- exit (-1);
- }
- cout <<flagv << endl << flagi << endl << flags << endl;
- return 0;
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement