#include <stdio.h>
#include <stdlib.h>

#ifdef WIN32
  #define USER "USERNAME"
  #define HOST "COMPUTERNAME"
#elif defined __unix__
  #define USER "USER"
  #define HOST "HOST"
#else
  #error Sorry don't know the environment variable(of the target platform).
#endif

int main()
{
    printf("%s says, \"Hello %s.\"\n", getenv(HOST), getenv(USER));

    getchar();
    return(0);
}
2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by athlon32
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.