Advertisement
Locoluis

Assignment

Sep 3rd, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main (int argc, char* argv[])
  6. {
  7.     int count=1;
  8.  
  9.     cout << "Welcome to the sample C++ program/n";
  10.  
  11.     //show all command line arguments
  12.     for (int i=0; i<argc; i++)
  13.         cout << "argv[" << i << "] = " << argv[i] << endl;
  14.  
  15.     //if no argument was given, prompt the user
  16.     if (argc==1) {
  17.         cout << "Enter number to repeat:";
  18.         cin >> count;
  19.     } else {
  20.         count = atoi( argv[1] );
  21.     }
  22.  
  23.     // show line a few times
  24.     for (int i=0; i<count; i++)
  25.         cout << "C++ is fun!/n";
  26.  
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement