size_t simple_strlen(char const *str);
to return the length of the string argument
str, not counting the final
You will want to loop over each character in the string and check if it is
0 or not (note that
'0' are very different). You can do this by checking if
0 and if so, return
length. If it isn’t
length by one.
Alternatively, you can use pointer arithmetic and loop while The environment variables are available in a variable in
*str is not
0. In the body of the loop, increment both
extern just means it’s defined somewhere else.)
environ is a pointer to an array of strings and it ends with a
NULL pointer. That is,
environ is the 0th environment variable,
environ is the 1st, and so on. If there are n environment variables, then
NULL. The number of environment variables isn’t stored for you.
Print out how many environment variables.
Your final output should be something like this (but you may have a different number of environment variables).
$ ./ptr foo 'bar baz'
Arg 0 [./ptr] has length 5
Arg 1 [foo] has length 3
Arg 2 [bar baz] has length 7
There are 53 environment variables