[ create a new paste ] login | about

Link: http://codepad.org/meO1hc23    [ raw code | output | fork ]

slevy1ster - C, pasted on Nov 7:
#include <string.h>
#include <stdio.h>

int main()
{
   const char str[80] = "This, is, \\n, www.tutorialspoint.com, \\n, website";
   const char s[2] = ", ";
   char *token;
   int count = 0;
   
   /* get the first token */
   token = strtok(str, s);
   
   /* walk through other tokens */
   while( token != NULL ) 
   {
      printf( " %s\n", token );
      count++;
      token = strtok(NULL, s);
   }
   printf("Token count is %d\n",count);
   return(0);
}


Output:
1
2
3
4
5
6
7
 This
 is
 \n
 www.tutorialspoint.com
 \n
 website
Token count is 6


Create a new paste based on this one


Comments: