title: C Delete last character in string
body: <p>I want to delete last character in string
  first, i use strtok function
  My Input is : <code>"Hello World Yaho"</code>
  I use <code>" "</code> as my delimeter</p>
  
  <p>My expectation is this</p>
  
  <pre><code>Hell
  Worl
  Yah
  </code></pre>
  
  <p>But the actual output is this</p>
  
  <pre><code>Hello
  Worl
  Yaho
  </code></pre>
  
  <p>How can I solve this problem? I can't understand this output</p>
  
  <p>this is my code</p>
  
  <pre><code>int main(int argc, char*argv[])
  {
     char *string;
     char *ptr;
     string = (char*)malloc(100);
  
     puts("Input a String");
     fgets(string,100,stdin);
  
     printf("Before calling a function: %s]n", string);
  
     ptr = strtok(string," ");
  
     printf("%s\n", ptr);
  
     while(ptr=strtok(NULL, " "))
     {
        ptr[strlen(ptr)-1]=0;
        printf("%s\n", ptr);
     }
  
     return 0;
  }
  </code></pre>