Since HOME is an environment variable, you should not prefix the $ sign.
char *value,name[20]; scanf("%s",name); value=getenv(name); if(value == NULL) printf("Not found"); else print("value = %s",value);
Make sure you include unistd.h and all relevant header files.
source share