Velocity Reviews

Velocity Reviews (
-   C++ (
-   -   Re: Environment Variables (

Artie Gold 07-26-2003 04:42 PM

Re: Environment Variables
Connell Gauld wrote:
> I am running Linux Mandrake 8.2.
> Im writing a program which requires the use of environment variables
> (reading only). The source code for my program, Test.cpp is as follows.
> #include <iostream.h>

#include <iostream>
#include <cstdlib>

> int main(){
> cout<<getenv("logname");

cout << std::getenv("logname");

Of course, you should be checking for a return value of NULL from

> return 1;

Return values other than 0 usually indicate a failure of some sort. Is
this what you mean?

return 0;

> }
> I have checked that the environment variable "logname" exists (which it
> does).
> After running:
> g++ Test.cpp
> I get this in the following error:
> 'getenv' undeclared

Which has nothing to do with the fact that "logname" is defined. You
haven't gotten that far.


Artie Gold -- Austin, Texas

All times are GMT. The time now is 06:02 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.