Answer Posted / manya
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
char * __mstrtok(char *str, char *delimiters)
{
int i;
char map[32];
char *dlmt = delimiters;
char *s1,*s2;
static char *laststr;
for(i=0;i<32;i++)
map[i] = 0;
for(;*dlmt;dlmt++)
map[*dlmt >> 3] |= 1 << (*dlmt & 7);
if(str)
s1 = str;
else
s1 = laststr;
if(!s1)
return NULL;
if(map[*s1 >> 3] & 1 << (*s1 & 7))
s1++;
s2 = s1;
for(;*s1;s1++)
{
if(map[*s1 >> 3] & 1 << (*s1 & 7))
{
*s1++ = '\0';
laststr = s1;
return s2;
}
}
return NULL;
}
int main()
{
char *token;
char string[] = "Hi friend, how are you? How is life! going
on, right.";
for(token=__mstrtok(string," ,?!.");
token;
token=__mstrtok(NULL," ,?!."))
printf("|%s|",token);
printf("\n Done \n");
return 0;
}
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is #define in c?
Write a C program to count the number of email on text
What is getch c?
Is it better to use a macro or a function?
What is function and its example?
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
Give the rules for variable declaration?
in linking some of os executables are linking name some of them
Is c++ based on c?
a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler
int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer
Can a function argument have default value?
Is c compiled or interpreted?
What is the scope of static variable in c?
Are pointers integers in c?