char* getenv(const char* name)
#include<unistd.h>
#include<stdio.h>
int main()
{
char environment_name[50];
printf("Enter the environment name: ");
scanf("%s",environment_name);
printf("Environment value: %s\n",getenv(environment_name));<br>
return 0;<br>
}<br>
setenv:- <br>
#include<unistd.h>
#include<stdio.h>
int main()
{
char variable_name[15];
char variable_Value[255];
int overwrittenValue<br>
printf("Enter the variable name: ");
scanf("%s",variable_name);
printf("Enter the variable value: ");
scanf("%s",variable_value);
printf("Enter the overridden value: ");
scanf("%d",&overwrittenValue);
int status = setenv(variable_name,variable_value,overwrittenValue);
if(status == 0)
{
printf("Environment variable created successfully.\n");<br>
}
else
printf("Environment variable not created\n"); <br>
return 0;<br>
}<br>
<br>
<b>unsetenv:</b> <br>
#include<unistd.h>
#include<stdio.h>
int main()
{
char variable_name[50];
printf("Enter the variable to delete: ");
scanf("%s",variable_name);
int status = unsetenv(variable_name);<br>
if(status == 0)
{
printf("Environment variable deleted successfully.\n");<br>
}
else
printf("Environment variable not deleted\n"); <br>
return 0;<br>
}<br>
<br><br>
It looks like you're new here. If you want to get involved, click one of these buttons!