Array of strings and char ** environ variable.

Posted by Naruto Uzumaki on Stack Overflow See other posts from Stack Overflow or by Naruto Uzumaki
Published on 2011-01-17T12:46:32Z Indexed on 2011/01/17 12:53 UTC
Read the original article Hit count: 234

Filed under:
|
|

Hello! I want to know how an array of strings is declared? What I do is I declare an array of pointers of pointers to strings. Eg.

char *array[]= {"string1","string2","string3"};

I was reading about modifying environment variables in Linux and stumbled upon the pointer char **environ ( http://www.cs.bham.ac.uk/resources/courses/2005/17423/doc/libc/Environment-Access.html#Environment-Access ).

char **environ is declared as an array of strings. I think it should be a pointer to a pointer. For eg.

char *array[]= {"string1","string2","string3"};
 environ = array;

Am I doing something wrong?

I also read somewhere that char *argv[] = char **argv. How is it possible?

© Stack Overflow or respective owner

Related posts about c

    Related posts about arrays