title: How to clear a string in C
body: <p>Is there a way in C to clear out my choice variable, so that on every loop it could be reused as a string variable input because each time I run the loop it works the first time through then doesn't take another input?</p>
  <pre class="lang-c prettyprint-override"><code>char choice [255];
  while (strcmp(choice,&quot;logout&quot;)!=0) {
      memset(choice, 0, strlen(choice));
      printf(&quot;what would you like to do?\n&quot;);
      printf(&quot;1 - login\n&quot;);
      printf(&quot;2 - who\n&quot;);
      printf(&quot;3 - Lookup\n&quot;);
      printf(&quot;4 - logout\n&quot;);
      scanf(&quot;%s&quot;,choice);
  
      if(strcmp(choice,&quot;login&quot;)==0){
          /* send server ip and player id*/
          printf(&quot;logging you in...&quot;);
      }
  
      if(strcmp(choice,&quot;who&quot;)==0) {
          /* send server ip and player id*/
          printf(&quot;fetching all available players...&quot;);
      }
  
      if(strcmp(choice,&quot;lookup&quot;)==0) {
          /* send server ip and player id*/
      printf(&quot;Who are you looking for?&quot;);
      }
  }
  </code></pre>