|
|
getenv() - Utility Function
|
Tutorials

Cpp

|
Topic |
How is Utility function "getenv()" used in C++?
How to Get the Environment String using C++?
|
|
Explanation |
|
getenv() is a Utility Function that returns a pointer to the environmental variable which is
given as an argument.This function returns a null terminated string or a NULL, if the variable does'nt exist.
Syntax to get the Environment String:
char *getnev(const char *name);
Example:
#include <stdlib.h>
#include <stdio.h>
int main ()
{
printf ("The current path is: %s",getenv("LIB"));
return 0;
}
|
Result:
The current path is: (null)
In the above example getenv() function returns a "NULL" value since the environmental variable for
"LIB" is not available.
|
| Note |
C++ is one of the most used programming languages in the world. Also known as "C with Classes".
Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.
|
|
|
|