title: Getting seg fault when trying to decrement my environment variable in C
body: <p>Total C noob here. I know there is something wrong with my <code>sprintf_wrapper</code> method because before I introduced it everything was working fine. The point of the function is to take a string buffer and a number and change the string buffers value to "WHALE=[num]". I then use this new string with <code>putenv</code> method.</p>
  
  <p>The code results in <strong>"Segmentation fault (core dumped)"</strong>, I believe it occurs after sprintf_wrapper is called.</p>
  
  <h1>Main Method</h1>
  
  <pre><code>int main(void) {
      getP0Info();
      putenv("WHALE=7");
      forkProcesses();
  
      int whale = atoi(getenv("WHALE"));
      char new_env[50];
      sleep(1);
      printf("P0: %d\n", whale);
      whale = whale - 1;
      sprintf_wrapper(new_env, whale);
      putenv(new_env);
  
      return 0;
  }
  </code></pre>
  
  <h1>sprintf_wrapper</h1>
  
  <pre><code>void sprintf_wrapper(char* str, int num) {
      char buffer[10];
      str = "WHALE=";
      sprintf(buffer,"%d", num);
      strcat(str,buffer);
  }
  </code></pre>