jpinto
asked on
Accessing argv outside of main in UNIX
With MSFT VC++ it is possible to obtain argv info trough a global variable defined in stdlib.g (__argv).
Is there a similar way to obtain argv info outside of main in UNIX/C ?
Thank you
Is there a similar way to obtain argv info outside of main in UNIX/C ?
Thank you
ASKER
If your answer was a peremptory "NO" (explaining why) I would accept it.
Obviously I could pass the argv parameter trough the program structure, but this does not appears to be "clean" programming.Instead I would prefer to declare a global variable and use it when needed.
The question is :
Is that global variable already defined in some include file ?
Is there a system call that enables the capture of this information (processual info) ?
Thanks anyway.
Obviously I could pass the argv parameter trough the program structure, but this does not appears to be "clean" programming.Instead I would prefer to declare a global variable and use it when needed.
The question is :
Is that global variable already defined in some include file ?
Is there a system call that enables the capture of this information (processual info) ?
Thanks anyway.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I accept that ! Although I am sorry !!!
in C (in unix) you have to define main as:
void main(int argc; char **argv)
the compiler will do the rest and you can reference the string with argv[0], argv[1] etc...
to obtain these values outside of main, you must pass the strings as a parameter. to the function you're calling
Mike