PDA

View Full Version : What is strtok function body?


martyr
Nov 3, 2003, 11:22 PM
What is strtok function body?

tadds
Nov 26, 2003, 07:56 AM
Here is an example of its use.
Not sure of it is what you were looking for.
-------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
  char buff[200], delim[50], *ptr;

  printf("Enter up to 175 characters to examine (s1): ");
  gets(buff);
  printf("Enter a string for the delimiter (s2): ");
  gets(delim);
  ptr = strtok(buff, delim);
  for (;;) {
     if (ptr == NULL) {
        break;
     }
     printf("\nptr = %s", ptr);
     ptr = strtok( (char *) 0, delim);     /* Note the null pointer */
  }
}