we declare main() as
int main(int argc, char *argv[])
and pass some argument by command line and use it
as argv[1], argv[2] in main() function definition but what if i want to use that in some other function’s definition ?
one things i can do it always pass that pointer char** argv from main() to that function by argument. But is there any other way to do so?
In order to make data available to other functions, you need to pass it as a parameter, or make it available through a global (not recommended) or a static variable.
The best approach is to make a function that parses command line parameters, and stores the results in a
structthat you define specifically for the purpose of representing command line arguments. You could then pass that structure around, or make it available statically or globally (again, using globals is almost universally a bad idea).