only main can accept arguments from the command line (argv). if you want to pass these command line args to a function then you need to pass them as a paramater.
#include <stdio.h>
int passingvars(int argc, char **argv)
{
int i = 0;
while (i < argc)
{
printf(argv[i]);
i++;
}
}
int main(int argc, char *argv[])
{
passingvars(argc, argv);
return 0;
}
2
solved Passing argument to sub-functions in C