getenv example in C
Syntax: char* getenv(const char* name)
Arguments Passed: Name of the environmental variable
Return Value: Value of the environmental variable if present else returns null
Code:
#include<stdio.h>
#include<stdlib.h>
int main()
{
printf("HOME Path :%s\n",getenv("HOME"));
printf("ROOT Path :%s\n",getenv("ROOT"));
printf("USER :%s\n",getenv("USER"));
printf("Present Working Directory: %s\n",getenv("PWD"));
return 0;
}
Comments
Post a Comment