title: C source code to change first letters of words from lowercase to uppercase in a string
body: <p>I have a C source code, but I have a problem with it. I want to convert the first letters of words in a string that I enter from lowercase to uppercase, but it changes all letters to uppercase. Can you help me solve this? </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;conio.h&gt;
  void main()
  {
      char sentence[100];
      int count, ch, i;
      int str[32];
      printf("Enter a sentence \n");
      for (i = 0; (sentence[i] = getchar()) != '\n'; i++)
      {
          ;
      }
      sentence[i] = '\0';
      /*  shows the number of chars accepted in a sentence */
      count = i;
      printf("The given sentence is   : %s", sentence);
      printf("\n Case changed sentence is: ");
      for (i = 0; i &lt; count; i++)
      {
          ch = islower(sentence[i])? toupper(sentence[i]) : tolower(sentence[i]);
          putchar(ch);
      }
      getch();
  }
  </code></pre>
  
  <p>e.g.</p>
  
  <p>Input: welcome to Sharif university</p>
  
  <p>Desired output:  Welcome To Sharif University</p>
  
  <p>Actual output: WELCOME TO SHARIF UNIVERSITY</p>