Re: Environment Variables

Discussion in 'C++' started by Artie Gold, Jul 26, 2003.

  1. Artie Gold

    Artie Gold Guest

    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
    std::getenv...

    > 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.

    HTH,
    --ag


    --
    Artie Gold -- Austin, Texas
     
    Artie Gold, Jul 26, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Kasten

    Setting Environment Variables

    Rick Kasten, Jul 7, 2004, in forum: Perl
    Replies:
    2
    Views:
    598
    Howard
    Jul 7, 2004
  2. =?Utf-8?B?YnNmbDQ0?=
    Replies:
    0
    Views:
    488
    =?Utf-8?B?YnNmbDQ0?=
    May 12, 2004
  3. darrel
    Replies:
    1
    Views:
    405
    Scott Allen
    Oct 4, 2004
  4. Replies:
    5
    Views:
    660
  5. Replies:
    9
    Views:
    957
Loading...

Share This Page