Cheap, dirty code for Windows and *nix.
"[computername] says, 'Hello [username].'" with getenv()
#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);
}
athlon32 56 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.