title: C Dynamic char array
body: <p>Expanding array dynamicly after user enter string in function <code>dynamic_array</code> My Problem seems to be when i try to use the extended array agian in main after i <code>dynamic_array</code> returns true.</p>
  
  <p>After function call i try to print <code>input</code> with <code>printf("main string: %s\n", input)</code> the program will crash. It seems like the <code>*input</code> in <code>main</code> never gets extended.</p>
  
  <pre><code>int dynamic_array(char *input, int *string_current_len){
    int string_len = 0;
    char temp_c;
  
    input = (char *) malloc(sizeof(char));
  
    if(input == NULL) {
      printf("Could not allocate memory!");
      exit(1);
    }  
  
    printf("File to search in: ");
  
    while((temp_c = getchar()) != '\n') {
      realloc(input, (sizeof(char)));
      input[string_len++] = temp_c;
    }
  
    input[string_len] = '\0';
  
    printf("\nYou entered the string: %s\n", input);
    printf("length of string is %d.\n", string_len);
  
  
    *string_current_len = string_len;
    return 1;
  }
  
  
  int main(void) {
    int string_len = 0;
    char *input;
  
    printf("enter #q as filename or word to quit.\n");
        if(!dynamic_array(input, &amp;string_len)){
         return 0;
        }
  
     printf("main string: %s\n", input);
     return 0;
  }
  </code></pre>