title: Getting the number of values in a char buffer (from file read) in C
body: <p>I would like to read characters from a file on a single line (for a school exercise). The exercise statest that the string is a maximum of 1000 characters. </p>
  
  <p>Using the following code I was able to read the file content in a char[]:</p>
  
  <pre><code>FILE *fp;
  const int buffsize = 1000;
  char *filepath = argv[1];
  char buff[buffsize];
  
  fp = fopen(filepath, "r");
  fscanf(fp, "%s", buff);
  //buff has the file contents
  </code></pre>
  
  <p>Considering these includes:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  </code></pre>
  
  <p>This seem to work fine however when I want to iterate over the array it goes way beyond the actual array length (because i fixed the buffsize at 1000 I assume). How could I approach this in a better way, so I can iterate over the correct number of indices? </p>