The ADDRESS environ is represented by four bytes on your architecture. So
sizeof(environ)==4, which explains your observation of only four iterations
of the loop.
To loop through the environ variables correctly, you should use something
like
for (i=0; environ[i]!=NULL; ++i) {...}
-----Original Message-----
From: Steven T. Hatton [mailto:hattons@globalsymmetry.com]
Sent: 25. mars 2003 09:59
To: suse-programming-e@suse.com
Subject: [suse-programming-e] looping through **environ?
Someone provided me this sample code getting the **environ variable from the
system and displaying it. It doesn't seem to work correctly. the body of
the for-loop executes four times. I believe there is far more data
available
than that. Am I correct in that assumption? If so, why is this code not
getting it all. It's been ages since I wrote any C/C++, and I was never
fluent in these languages. I recall that working with pointers can be
tricky. By the example on 58 of Ellis & Stroustrup I am lead to believe the
code below should work. Any suggestions?
#include