Advertisement
Guest User

Untitled

a guest
Mar 26th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1.  
  2. void ShowUsage()
  3. {
  4. cout<<"Usage 1 (arguments):\n\t Example IP Port Username Password [SleepIntervalSecond]"<<endl;
  5. cout<<"Usage 2 (stdin):\n\t Example "<<endl;
  6. }
  7.  
  8.  
  9. int main(int argc, char* argv[])
  10. {
  11.  
  12. string IP, UserName, Password;
  13. unsigned short Port = 0;
  14. int SleepIntervalSecond = 20;
  15.  
  16. if(argc == 1)
  17. {
  18. cerr << "IP:";
  19. cin >> IP;
  20. cerr << "Port:";
  21. cin >> Port;
  22. cerr << "UserName:";
  23. cin >> UserName;
  24. cerr << "Password:";
  25. cin >> Password;
  26. cerr << "SleepIntervalSecond:";
  27. cin >> SleepIntervalSecond;
  28. }
  29. else if (argc > 4)
  30. {
  31. IP = argv[1];
  32. Port = atoi(argv[2]);
  33. UserName = argv[3];
  34. Password = argv[4];
  35. if (argc > 5)
  36. {
  37. SleepIntervalSecond = atoi(argv[5]);
  38. }
  39. }
  40. else
  41. {
  42. ShowUsage();
  43. exit(0);
  44. }
  45.  
  46. cout << "====================" <<endl;
  47. cout << " IP:" << IP.c_str() <<endl;
  48. cout << "PORT:" << Port <<endl;
  49. cout << "USER:" << UserName.c_str() <<endl;
  50. cout << "PASS:" << Password.c_str() <<endl;
  51. cout << "INTERVAL:" << SleepIntervalSecond << "s" <<endl;
  52. cout << "====================" <<endl;
  53.  
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement