I am trying to read an environment variable on windows platform. I made the variable global as I intend to use it through various function. This is what I tried
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
char* devset = getenv("DEVSET"); //1 for debugging, 0 for normal execution
I get the error
C:\Users\Prateek\Documents\Script Parser\main.c|6|error: initializer element is not constant
I tried the same thing in main, it compiled and I didn't get any errors. However this way I will be required to pass the environmental variable as an argument to all the functions. Is there another approach to make the environment variable globally accessible? Any help appreciated.
Aucun commentaire:
Enregistrer un commentaire