Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
728 B
2
Indexable
Never
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int main(int argc, char **argv, char **envp)
{
    char line[100];
    cin.getline(line, 100, '\n');
    string userInput(line);
    int sum = 0;
    while (userInput.compare("") != 0)
    {
        if (userInput.compare("__all__") != 0)
        {
            sum++;
            cout <<line << "=" << getenv(line) << '\n';
            cin.getline(line, 100, '\n');
            userInput.assign(line);
        }
        else
        {
            for (char **env = envp; *env != 0; env++)
            {
                char *thisEnv = *env;
                printf("%s\n", thisEnv);
            }
            return 0;
        }
    }
    return sum;
}