This repository has been archived on 2022-10-18. You can view files and clone it, but cannot push or open issues or pull requests.
HPC/Project0/src/read_environment.cpp

24 lines
662 B
C++
Raw Normal View History

2022-09-20 14:38:03 +00:00
// THIS PROGRAM REQUIRES NO MODIFICATION
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
{
const char *uname = std::getenv("USER");
const char *gcc = std::getenv("GCC_ROOT");
const char *nodes = std::getenv("SLURM_JOB_NODELIST");
if (uname && gcc && nodes && argc == 2)
{
std::cout << "Your name is: " << argv[1] << '\n';
std::cout << "Your username is: " << uname << '\n';
std::cout << "Your gcc root is: " << gcc << '\n';
std::cout << "You're connected to: " << nodes << '\n';
}
else
{
std::cout << "Something went wrong...\n";
}
}