#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
int i;
i = 1;
while (i < argc) {
cout << argv[i] << endl;
i = i + 1;
}
}
Command line arguments are listed as b f i
I'm just learning about argc and argv, but from what I understand, argc is the number of arguments passed from the command line (3 in this case), and argv is the array of these arguments, [b f i] in this case. So using that, I intuitively think that this loop should output argv[1], then argv[2], then terminate. The final output would therefore be:
f
i
However, the solution given is:
b
f
i
Which is baffling to me. Would anyone be able to explain where I'm going wrong with my thought process?