Table of contents
What is putenv() in c?
putenv in c is a c standard function used to change the environmental variable value.
It is defined in stdlib.h header file.
Prototype
int putenv(char *strng);
Return value
It returns 0 on success -1 on error.
putenv in c program example
// C program to illustrate putenv function
#include<stdio.h>
#include<stdlib.h>
int main()
{
int res=putenv("NAME=TST");
if(res==0)
printf("Value of environment variable written is :%s \n",getenv("NAME"));
else
printf("Error on writing variable\n");
return 0;
}
Output
Code explanation
The putenv() changes the environment variable value.
People also ask for
What is putenv() in c?
This function is used to change the environmental variable value. It is defined in stdlib.h header file.