Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main ()
{
char input[100], *tokenptr;
int lenth,i=0,j,temp,count=0;
printf("Enter string to Tokenize : ");
gets(input);
lenth=strlen(input); //calculating length of string by built in function
tokenptr=strtok(input, " "); // tokenizing string on bases of space
while(tokenptr!=NULL) // while loop until null character is found
{
printf("%s \n",tokenptr); //printing token
tokenptr=strtok(NULL, " "); //passing NULL as the first parameter to tell function to resume from the last spot left in the string.
}
Post a Comment