User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed



    #include <stdlib.h>
    char *getenv(const char *name);

getenv matches the string pointed to by name

returns a pointer to the value in the environment, or NULL if there is no match.

getenv C Sourcecode Example

 * getenv example code
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
#include <stdlib.h>
int main ( void )
  char *env;
  env = getenv ("USER");
  if (env!=NULL) {
    printf ("Your Username is: %s\n", env);
  return 0;


  user@host:~$ ./getenv 
  Your Username is:

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdlib.h/getenv.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz