title: Reading a line from file in C, dynamically
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      FILE *input_f;
  
      input_f = fopen("Input.txt", "r"); //Opens the file in read mode.
      if (input_f != NULL)
      {
          char line[2048];
  
          while( fgets(line, sizeof line, input_f) != NULL )
          {
              //do something
          }
          fclose(input_f); //Close the input file.
      }
      else
      {
          perror("File couldn't opened"); //Will print that file couldn't opened and why.
      }
      return 0;
  }
  </code></pre>
  
  <p>Hi. I know I can read line by line with this code in C, but I don't want to limit line size, say like in this code with 2048. </p>
  
  <p>I thought about using malloc, but I don't know the size of the line before I read it, so IMO it cannot be done. </p>
  
  <p>Is there a way to not to limit line size?</p>
  
  <p>This question is just for my curiosity, thank you.</p>