title: Calling a function to return a string inside another function call in c
body: <p>I am currently working on a program with the Dante Brooklyn II board from audinate. I am trying to use a void return function from the Dante API - foo() - that needs to have 3 various structs passed in as well as 2 strings. I have another function get_value_by_key() which returns the string value that I need.
  I initially tried calling on the program like so:</p>
  
  <pre><code>    foo(struct, struct, struct, get_value_by_key(key1), get_value_by_key(key2);
  </code></pre>
  
  <p>When I run it this way, the program twists the returned strings of get_value_by_key() and crashes the entire program. I have, however, found an alternative that works, but it is longer and I would like to not waste the extra processing power. The alternative is here:</p>
  
  <pre><code>    char value1[15], value2[15];
      strcpy(value1, get_value_by_key(key1));
      strcpy(value2, get_value_by_key(key2));
      foo(struct, struct, struct, value1, value2);
  </code></pre>
  
  <p>I cant seem to decipher why the Brooklyn board shuts down with the first command, and not the second. Any help at all would be much appreciated.
  This is the code for get_value_key(). Pretty simple logic here:</p>
  
  <pre><code>    char * get_value_by_key(command_t command, char key[50]){
           int i;
           char value[50];
           for(i = 0; i &lt; NUM_PARAMETERS; i++){
               if(strcmp(user_command.command_parameter[i].key, key) == 0){
                   strcpy(value, user_command.command_parameter[i].value);
               }
           }
           return value;
       }
  </code></pre>