Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ffcccc
char *temp;
char *copy;

if ((temp = getenv("TEST_ENV")) != NULL) {
  copy = malloc(strlen(temp) + 1);
  if (copy != NULL) {
    strcpy(copy, temp);
  }
  else {
    /* handle error condition */
  }
}

/* ...program code... */
setenv("TEST_ENV", var, 1);
/* ...program code... */


printf("TEST_ENV: %s\n", temp);
printf("TEST_ENV: %s\n", copy);

...

Code Block
bgColor#ccccff
char *temp;
char *copy;

if ((temp = getenv("TEST_ENV")) != NULL) {
   copy = malloc(strlen(temp) + 1);
   if (copy != NULL) {     
      strcpy(copy, temp);   
   }
   else {
      /* handle error condition */
   }
}

/* ...program code... */
setenv("TEST_ENV", var, 1);
/* ...program code... */

if ((temp = getenv("TEST_ENV")) != NULL) {
   copy = malloc(strlen(temp) + 1);
   if (copy != NULL) {    
      strcpy(copy, temp);  
   }
   else
   {     
      /* handle error condition */   
   }
}

printf("TEST_ENV: %s\n", temp);
printf("TEST_ENV: %s\n", copy);

...