title: C change words beginning with lowercase to capital in text file
body: <p>Well I try to read a file and change every word that's beginning with a lowercase to the same word beginning with an uppercase.</p>
  
  <p>This is what i got:</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
  FILE *fp;
  int zeichen;
  
  fp = fopen("test.txt", "r+");
  
  if(fp == NULL){
      printf("Die Datei konnte nicht geoeffnet werden.\n");
  }
  else{
      fseek(fp, 0L, SEEK_SET);
      zeichen = fgetc(fp);
      while(zeichen != EOF){
          if(zeichen == ' '){
              fseek(fp, 1L, SEEK_CUR);
              if(('a' &lt;= zeichen) &amp;&amp; (zeichen &lt;= 'z')){
                  zeichen = fgetc(fp);
                  fputc(toupper(zeichen), fp);
              }
          }
          zeichen = fgetc(fp);
      }
      zeichen = fgetc(fp);
      fclose(fp);
  }
  return 0;
  }
  </code></pre>
  
  <p>My test.txt file does not change at all.</p>
  
  <p>Any suggestions what i am doing wrong?</p>
  
  <p>EDIT:</p>
  
  <p>Thank you for the different ways to achieve my task.</p>
  
  <p>Most of them where using stuff i didn't learn yet, so i tried it by copying the characters from one file to another + making the first letter of each word an uppercase by toupper() cause it's indeed easy to use. Then deleting the old file + rename the new one.</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  
  int main()
  {
      FILE *fp, *neu;
      int zeichen;
  
      fp = fopen("test.txt", "r");
      neu = fopen("new.txt", "w");
  
      if(fp == NULL) {
          printf("Die Datei konnte nicht geoeffnet werden.\n");
          exit(EXIT_FAILURE);
      }
  
      while((zeichen = fgetc(fp)) != EOF) {
          if(zeichen == ' ') {
              fputc(zeichen, neu);
              zeichen = fgetc(fp);
              zeichen = toupper(zeichen);
              fputc(zeichen, neu);
          }
          else{
              fputc(zeichen, neu);
          }
      }
      fclose(fp);
      fclose(neu);
      remove("test.txt");
      rename("new.txt", "test.txt");
      printf("File has been changed.\n");
      return 0;
  }
  </code></pre>