Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: reformatted examples to be consistent

...

Code Block
bgColor#FFcccc
langc
char *tmpvar;
char *tempvar;

tmpvar = getenv("TMP");
if (!tmpvar) {
  return -1;
}
tempvar = getenv("TEMP");
if (!tempvar) {
  return -1;
}
if (strcmp(tmpvar, tempvar) == 0) {
  if (puts("TMP and TEMP are the same.\n") == EOF) {
    /* Handle error */
  }
}
else {
  if (puts("TMP and TEMP are NOT the same.\n") == EOF) {
    /* Handle error */
  }
}

...

Code Block
bgColor#ccccff
langc
char *tmpvar;
char *tempvar;
size_t len;

errno_t err = _dupenv_s(&tmpvar, &len, "TMP");
if (err) {
  return -1;
}
err = _dupenv_s(&tempvar, &len, "TEMP");
if (err) {
  free(tmpvar);
  tmpvar = NULL;
  return -1;
}

if (strcmp(tmpvar, tempvar) == 0) {
  if (puts("TMP and TEMP are the same.\n") == EOF) {
    /* Handle error */
  }
}
else {
  if (puts("TMP and TEMP are NOT the same.\n") == EOF) {
    /* Handle error */
  }
}
free(tmpvar);
tmpvar = NULL;
free(tempvar);
tempvar = NULL;

...