argv[1] not recognised outside of main
Hi
This is a C programming question. I have a function that gets called from main. In the definition of the function i use getaddrinfo. One of getaddrinfo's arguments is argv[1]. Because this function is defined outside of main, gcc complains that this function doesn't know what argv[1] is. I put the networking code in this function in question because sendto(this is a UDP client) doesn't know what the res structure is if i put it in main. Do i pass *argv[] as an argument to this function in question or what? I can post the code if you want. thank you very much for your time. |
Oh i just did:
char **arg as a global array. Then: arg = argv in main. The compiler doesn't complain about this. Please just reply if you don't think the solution is right! |
It's OK. What I usually do is to pass argv as a parameter to the function that is being called.
|
Quote:
Code:
char *address = argv[1] |
All times are GMT -5. The time now is 12:03 AM. |