Introduction
c,,,
,
Requirement
Command Line Arguments
Pass information in from the command line of your program
Passed in as a c-string
int main(int argc, char argv[])
argc is the number if items on the command line
The program name is included so argc is always at least = 1
argv is an array of c-strings where each element is a “word” from the command line
argv[0] is always the name of the program
Inside foo.cpp when called as
foo duck drop roll
int main(int argc, char argv[])
Then
argc = 4
argv[0] = “foo”
argv[1] = “duck”
argv[2] = “drop”
argv[3] = “roll”
Example:
int main(int argc, char *argv[])
{
for (int i=0; i