title: C: Segmentation fault while reading user input with fgets
body: <p>I'm new to C and I'm trying to write a program with a lot of user input. For that purpose I wrote this function: </p>
  
  <pre><code>char * addValue(char * msg){
      char * input[80];
      printf("%s", msg);
      fflush(stdout);
      fgets(*input, 80, stdin);
      strtok(*input, "\n");
      return *input;
  }
  </code></pre>
  
  <p>This function works perfectly in the whole program except in this part:</p>
  
  <pre><code>struct User{
      char userid[10];
      char email[80];
      char name[80];
      char password[80];
      char downloaded[10];
      char registred[10];
  };
  
  int change() {
      char * query = "SELECT * FROM Users WHERE user_id=";
      char * userid = addValue("Enter the User ID: "); // Works here
      // Here is a MySQL query
      char * email = addValue("Mail: "); // -&gt; Segmentation Fault
      printf("%s\n", email);
      struct User usrvalues;
      strcpy(usrvalues.email, email);
      return 0;
  }
  </code></pre>
  
  <p>I have absolutely no idea, why the second function call is not working. I have other functions in the program where I call the addValue() function multiple times without any errors.</p>
  
  <p>When I debug this with gdb, I get this result:</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  0x00007ffff6445b77 in __GI__IO_getline_info () from /usr/lib/libc.so.6
  </code></pre>
  
  <p><code>bt</code> gives me the following informations:</p>
  
  <pre><code>#0  0x00007ffff6445b77 in __GI__IO_getline_info () from /usr/lib/libc.so.6
  #1  0x00007ffff6444a3d in fgets () from /usr/lib/libc.so.6
  #2  0x000000000040142b in addValue ()
  #3  0x00000000004016e9 in change ()
  #4  0x0000000000401bd0 in main ()
  </code></pre>
  
  <p>I tried different inputs ("" (an empty string), different numbers like 100 and different strings like "test"), but it every time it ends with a segmentation fault.</p>
  
  <p>What am I doing wrong?</p>