title: In C, use a while loop to count the number of characters a user inputs
body: <p>I'm a complete newbie to programming and am having a lot of trouble with something I know is very basic. I create a program where the user inputs a word and I must use a while loop to calculate the number of characters in the word and show the result on screen.</p>
  
  <p>I'm fine with having the user input the word but my problem is with the while loop. I just can't understand how to code it. I really would appreciate some help with this.</p>
  
  <p>Thanks</p>
  
  <p>Edit:</p>
  
  <p>Here's what I've done so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main(void)
  {
  char input[30]; 
  int wordlen;
  
  printf("please enter a word: \n");
  scanf("%29c", input);
  
  while (input &lt; 30);
  {
  /*Not sure what to put in here*/
  printf("Number of letters in input is %s", /*???*/);
  }
  
  return 0;
  }
  </code></pre>
  
  <p>Another edit: This is homework but my lecturer is rubbish and doesn't explain things well. I'm trying to learn and would like to understand how it works I'm not necessarily expecting a direct answer. Even some hints as to how to solve it myself would be great. Thanks</p>
  
  <hr>
  
  <p>Ok after much trial and error here is what I have come up with. I think it is correct but would like your opinions on it. Please bear in mind I have been doing C for less than 3 weeks so my technique might be poor. Thanks for your input everyone.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main(void)
  {
  char input[30]; 
  int i;
  int x;
  x=0;
  
  printf("please enter a word: \n");
  scanf("%29s", input);
  i=strlen(input);
  
  while (x &lt; i)
  {
   x++;
  }
   printf("Number of letters in input is %d", x);
  
  
  return 0;
  }
  </code></pre>