daily pastebin goal
36%
SHARE
TWEET

I HAVE NO IDEA WHAT I AM DOING

RandomGuy32 Nov 2nd, 2017 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <unistd.h>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char *argv[]) {
  7.     char opt;   // ?
  8.  
  9.     while ((opt = getopt(argc, argv, "hs:")) != -1) {
  10.         switch (opt) {
  11.             case 'h':
  12.                 cout << "Usage: " << argv[0] << "-s [integer amount]\n";
  13.                 break;
  14.             case 's':
  15.                 /*if ((int) optarg < 1) {
  16.                     cerr << "Amount must be at least 1. Your input: " << optarg << "\n";
  17.                     return 2;
  18.                 }
  19.                 else*/ {
  20.                     cout << (int) optarg << "\n";
  21.                     cout << "Please enter " << optarg << " integers.\n";
  22.  
  23.                 }
  24.  
  25.                 break;
  26.             default:
  27.                 cerr << "Unknown Argument: " << opt << "\n";
  28.                 return 1;
  29.         }
  30.     }
  31.  
  32.     return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top