title: Issue with printing char pointer in C
body: <p>I am calling a function of return type struct Function, as specified below:</p>
  
  <pre><code>typedef enum {string,integer} ReturnType;
  typedef struct Function{
      ReturnType returnType;
      char *token;
      char *tokenProgress;
      char *result;
      void (*init)(struct Function *self);
  } Function;
  void Function_init(Function *self, ReturnType returnType,char *token, char *tokenProgress){
      self-&gt;returnType = returnType;
      self-&gt;token = token;
      self-&gt;tokenProgress = tokenProgress;
      self-&gt;result = "";
  }
  </code></pre>
  
  <p>In the main loop of my program I want to print the result pointer contained within the struct, like so:</p>
  
  <pre><code>int main(int argc, const char * argv[]){
      while(true){
          scanf("%s",command);
          Function *func = executeCommand(command);
          printf("%s\n", func-&gt;result);
      }
  }
  </code></pre>
  
  <p>Here is executeCommand:</p>
  
  <pre><code>Function * executeCommand(char command[]){
      Function *currentFunction;
      char *token;
      char *tokenProgress;
      Function_init(currentFunction,integer,token,tokenProgress);
      char result[11];
      sprintf(result,"%d",3);
      currentFunction-&gt;result = result;
      return currentFunction;
  }
  </code></pre>
  
  <p>However, when I run the program, only a newline character is printed when it should print "3\n". I have run the program using gdb to check that <code>func-&gt;result</code> has a value:</p>
  
  <pre><code>(gdb) print func-&gt;result
  (char *) $0 = 0x00007fff5fbffa9d "3"
  </code></pre>
  
  <p>I checked this value at a breakpoint placed on the line printing <code>func-&gt;result</code>, so I am at a loss as to why it is not printing since it clearly has a value and the struct is being returned correctly.</p>