title: Getting unlimited input in C?
body: <p>So I'm trying to program a function which allows the user to enter an unlimited amount of chars. For example this:</p>
  
  <pre><code>char string[100]
  </code></pre>
  
  <p>limits the input to 100 characters.</p>
  
  <p>The code i have so far is:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  char* uinput(){
      char *string, *current;
      int counter = 0;
      string = (char *) malloc(10 * sizeof(char));
      do{
          realloc(string, counter * sizeof(char));
          current = string + counter;
          *current = getchar();
          counter++;
      }while(*current != '\n');
      return string;
  }
  
  int main(){
      char *s;
      s = uinput();
      printf("\nYou entered: %s", *s);
      return 0;
  }
  </code></pre>
  
  <p>I'm new to pointers, so I'm not sure why this doesn't work(Program crashes). What I'm trying to do is keep reading a character and keep relocating  the string pointer so the amount of bytes keeps increasing until the user presses enter ('\n').</p>
  
  <p>Thanks
  ~Raf</p>