Command line arguments
On this page
Command line arguments
Passing arguments to main
In the above video, I compile in an older version of our environment with clang++-10. In your updated
environment, you should use clang++.
Q1
QQ1
This question is ungraded.
According to the lesson videos, if you are interested in using an argument stored in argv in your program, how should you interact with its value?
Q2
QQ2
This question is ungraded.
Assume you have compiled a C++ program with a main(int argc, char* argv[]) function down to the executable a.out.
If you execute ./a.out "Howdy, World" from the command line, what will be stored in argv[0]?
Q3
QQ3
This question is ungraded.
Assume you have compiled a C++ program with a main(int argc, char* argv[]) function down to the executable a.out. If you execute ./a.out from the command line, what will be stored in argc?
Q4
QQ4
This question is ungraded.
Given the following program code:
#include <iostream>
int main(int argc, char* argv[]) {
if (argc != 1) {
std::cout << "Usage: " << argv[0] << std::endl;
return 1;
}
std::cout << "Whoop!" << std::endl;
return 0;
}
Assume you have compiled that program down to the executable a.out. If you execute ./a.out Howdy, World! from the command line, what will be the output of the program?