title: Stop a for loop when user is finished entering input in c
body: <p>First of all, thank you for the assist!</p>
  
  <p>I'm new to the C language (and programming in general) and I'm trying to write a program wherein the user inputs data points. The data points are then saved in an array where they can then be manipulated. </p>
  
  <p>Where I am stuck: I want the user to be able to input (almost) any number of points, then use a 'keyword' of sorts to signal the end of data entry. In this case, the user would type 'done'. </p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main(void) {
  
  printf("\n Welcome! \n\n Please enter each data point. Enter 'done' when finished.\n\n");
  
  double data[1048];
  int i, count;
  
  for (i = 1; ;i++) {
  
      printf("Data[%i]: ", i);
      scanf("%lf", &amp;data[i]);
  
      if (data[i] == 'done') {
  
          break;
  
      } else {
  
          count++;
  
      }
  
    } 
  
  }
  </code></pre>
  
  <p>I've tried 'return 1;' and 'break;'. Each time, the program works well until the 'keyword' is entered, at which point I get:</p>
  
  <pre><code>Data[8]: Data[9]: ... Data[1120]: Data[1Segmentation fault 11 
  </code></pre>
  
  <p>The only time it works is if I have it break when the user inputs a particular number (like -1 or 0). But that doesn't quite work for the user since they might have to enter those numbers as data points.</p>
  
  <p>Sorry for the long post, but I appreciate the help!</p>