csci4061/notes/03-process-basics-code/environment_vars.c
Michael Zhang 041f660ccd
f
2018-01-29 17:28:37 -06:00

27 lines
501 B
C

#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]){
char *verbosity = getenv("ROCK");
if(verbosity == NULL){
printf("ROCK not set\n");
}
else{
printf("ROCK is %s\n",verbosity);
printf("Turning VOLUME to 11\n");
int fail = setenv("VOLUME","11",1);
if(fail){
printf("Couldn't change VOLUME\n");
}
}
char *volume = getenv("VOLUME");
if(volume == NULL){
volume = "not set";
}
printf("VOLUME is %s\n",volume);
return 0;
}