Created
November 19, 2012 04:21
-
-
Save trevorrjohn/4108934 to your computer and use it in GitHub Desktop.
argv example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if we had the program | |
int main(int argc, char* argv[]) { | |
cout << "output is: "; | |
for(int i = 0; i < argc; i++) | |
cout << argv[i] << ", "; | |
cout << endl; | |
return 0; | |
} | |
// Given this input | |
$ ./a.out a b c | |
output is: a.out, a, b, c, | |
$ ./a.out -f somefile | |
output is: a.out, -f, somefile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment