Arguments from shell to main.cpp

Hello everybody.
I have a problem how to handle three arguments giving to main(int argc, char **argv).
I have to implement a programm that receives first a datafile as input, the second argument is a double number and the third is a bool variable, so that I starts the programm as follows:

execute ./filename.txt 0.75 true

How can I handle these three arguments and reading them out in a char, a double and a bool variable???

Do tou have any idea?
In that example, you'll get:
argc == 4
argv[0] = execute
argv[1] = ./filename.txt
argv[2] = 0.75
argv[3] = true

argv is a pointer to strings, so all the arguments are strings. You have to convert argv[2] to a double yourself (possibly by calling atof()).
Topic archived. No new replies allowed.