It get environmental variables and displays them
#include <iostream>
#include <string>
#include <filesystem>
#include <Windows.h>
int main() {
std::string keep_open;
// Check to see if env variables were successfully retrieved
if (std::getenv("USERNAME") != nullptr && std::getenv("NUMBER_OF_PROCESSORS") != nullptr && std::getenv("PROCESSOR_LEVEL") != nullptr && std::getenv("OS") != nullptr) {
// Create the array to hold the info gathered from the env variables
std::string info_array[4] = {
std::getenv("USERNAME"),
std::getenv("NUMBER_OF_PROCESSORS"),
std::getenv("PROCESSOR_LEVEL"),
std::getenv("OS")
};
// Display the contents of the array one by one
std::cout << info_array[0] << "\n";
std::cout << info_array[1] << "\n";
std::cout << info_array[2] << "\n";
std::cout << info_array[3] << "\n";
std::cin >> keep_open;
} else {
// Display the error if it couldn't correctly get one of the env variables
DWORD error = GetLastError();
std::cout << "ERROR: " << error;
std::cin >> keep_open;
std::exit(0);
}
}