Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Length of envp in C

Tags:

c

In the proccess of learning C, I'm trying to write a program that accepts one of your environment variable as input, and outputs its value.

The question is, is there any way to know the length of envp? I mean, how many envp is there? I'm aware that it is a char** - an array of string. And finding the size of array in C is problematic already. What can I do to know the size of envp?

Please just provide direction, not the concrete answer (or code).

like image 332
bertzzie Avatar asked Aug 11 '11 04:08

bertzzie


1 Answers

It's terminated by a NULL pointer. You have to count it if you want to know the length.

like image 176
Ben Jackson Avatar answered Sep 25 '22 13:09

Ben Jackson