Below is the general syntax for environ. Is char **environ a pointor to a pointor?? I am sure it means something else... please explain..
Code:#include <stdlib.h> extern char **environ;
Below is the general syntax for environ. Is char **environ a pointor to a pointor?? I am sure it means something else... please explain..
Code:#include <stdlib.h> extern char **environ;
Nope, that's exactly what it is. A pointer to a pointer to a char.
Although it is interpreted as a pointer to an array of pointers, each of which points to a C-style string.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Yes it is.
Use it like you would the char **argv that main() receives.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
It is a pointer to an array of char pointers. In other words, an array of strings where environ[0] is the first, environ[1] is the second, etc. It is exactly like argv but lists the environment variables instead of the command line arguments.
I would suggest against accessing it directly. You should go through getenv() instead.
Thank you all for your replies!! I really appreciate