Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does envp stand for?

Tags:

c++

c

argv

I wonder what the abbreviation envp stands for, for example here:

int main(int argc, char **argv, char **envp);

I also wonder what the v in argv initially stood for. Was the v for "value"? Or maybe "vector"?

like image 371
nngm Avatar asked Jun 06 '26 11:06

nngm


1 Answers

The meaning is:

  • argv stands for argument vector
  • argc for argument count, and
  • envp for environment pointer.

We can discuss about the good or bad naming convention, but it's a historic usage that dates back to the beginning of the C language: B.W.Kernighan and D.Ritchie used already argc and argv for main() in their first edition of The C Programming language in 1978.

The envp was added later from the UNIX development and is an alternative for using the environ pointer. I found a reference to it in a book from 1986, but it's certainly even older. It doesn't need a count, because it's null terminated. Note that it is not portable and therefore the use of getenv() should be preferred.

like image 71
Christophe Avatar answered Jun 09 '26 00:06

Christophe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!