There is such code:

void initializeSuplies(int paper) { char paperBuffer[10]; snprintf(paperBuffer, 10, "%d", paper); setenv("PAPER", paperBuffer, 1); } 

I want to understand what is being recorded and how? Are environment variables used only in unix?

You can by points:

  1. The initializeSuplies () function is called.
  2. An array of paperBuffer is created.
  3. ?
  4. ?
  • one
    They teach them dos'u in universities, they teach, and they forget about variable environments. (Shyutka) But in general - POSIX.1-2001 - alexlz

1 answer 1

The environment shuffles are also in Windows , if you believe MSDN you need to use the _putenv, _wputenv (for unicode ) functions for this - see MSDN for more details.

The setenv () function ( UNIX ) adds an environment variable with the value in the first parameter if it does not exist. If the variable already exists, its value is changed to the one specified in the second parameter, provided that the overwrite flag (the third parameter) is not zero, and if it is zero, then the value of the environment variable does not change (i.e., such a call to nothing will lead).
setenv () returns 0 on success, and -1 in other cases.

The unsetenv () function removes the specified variable from the environment.

  • one
    Again, what have the "unih"? The feature is included as standard. If MS spat on standards is another question. mingw gcc I have found this function in the standard library - alexlz