EvilZone
Programming and Scripting => C - C++ => Topic started by: kenjoe41 on August 12, 2013, 05:52:10 PM
-
Ok, am convinced there is nothing wrong with this code. But i wonder why it won't compile in code::blocks or g++.
Here is the code:
// This program prints its environment variables.
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
extern char **environ; // Needed to access the environment
int k = 0;
while(environ[k] != 0) // Is it last C-string in environment?
{
// Print the string
cout << environ[k] << "\n";
k++;
}
return 0;
}
-
Never used environ(). I looked at the documentation of it though and it looks like you just forgot to include the stdlib.h header.
-
Ok, that just did the magic. i will remember next time to consider the documentation.