I want to create a program that reads the name of the file after the the command line.
For instance the name of my program is main.cpp
The user executes my program by typing:
./main input1.txt
I want main to read the string "input1.txt". How do I do that?
Do you mean
|
int main (int argc, char *argv[])
|
?
Last edited on
An array is a specialized pointer, essentially, so *argv[] is (roughly) the same as **argv as far as arguments are concerned.
Yes, that's what he meant. Use the *argv[] form. It is canonical.