Advertisement
Guest User

parser.cpp

a guest
Jul 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4.  
  5. //разбор параметров
  6. int main(int argc, char* argv[])
  7. {
  8.   bool to_screen;
  9.  
  10.   int i;
  11.   for (i=0;i<argc;i++)
  12.   {
  13.     if (argc > i && argv[i]=="./appname -s screen")
  14.     {
  15.       to_screen = true;
  16.       std::cout << argv[i] << std::endl;
  17.     }
  18.  
  19.     else if (argc < i || argv[i]=="./appname -s log")
  20.     {  
  21.     //пишем в zmq.log
  22.       std::ofstream file;
  23.       file.open("zmq.log");
  24.       file<<argv[i];
  25.       file.close();
  26.       to_screen = false;
  27.     }
  28.     else {
  29.     //если ошибка другого вида , все равно пишем в zmq.log
  30.       std::ofstream file;
  31.       file.open("zmq.log");
  32.       file<<argv[i];
  33.       file.close();
  34.       to_screen = false;
  35.     }
  36.   }
  37. //нарушена логика , не работает
  38.   return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement