How to pass Arguments to Main?

May 14, 2015 at 8:42pm
My main in a program looks like:

 
int main(int argc, char* argv[]){...}



I want to use Linux to compile my program, but I don't know how to pass arguments in for argc and argv. How do I do that?

May 14, 2015 at 8:44pm
when you run your program from the command line:
http://www.tutorialspoint.com/cprogramming/c_command_line_arguments.htm

OR if you are using an IDE in linux there must be an option somewhere to specify your arguments when you run your code.
Are you using an ide? If so which one?
May 14, 2015 at 9:34pm
These arguments are passed in at run time, not at compile time. You simply pass a space separated list of arguments after you program name at the command line (terminal, prompt, etc.) argc will equal the number of arguments passed in plus one, and argv will hold all these arguments' values, the first being argv[1]. (argv[0] holds the program name.)
Topic archived. No new replies allowed.