Answer to Question #552 in C++ for Peter

Question #552
How can I identify command line parameters my program was started with?
1
Expert's answer
2010-08-09T10:33:42-0400
To do this, you should check the variables argc and argv which contain respectively the number and the values of the parameters: int main(int argc, char* argv[]){}. Argument with index 0 is the name of the running program. The following values are the parameters of the program starting. For example:

./programm safe quick
argc = 3
argv[0] = /home/user/programm
argv[1] = safe
argv[2] = quick

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS