logo

How to get environment variables in C

#include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[], char* envp[]) { char* env_variable = getenv("API_KEY"); if (env_variable == NULL) { printf("No environment variable was found\n"); return 1; } printf("The value of our environment variable is %s\n\n", env_variable); return 0; }