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 are the types of data types and explain?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
Are c and c++ the same?
Can you please explain the difference between strcpy() and memcpy() function?
What is getch?
How can my program discover the complete pathname to the executable from which it was invoked?
How can a process change an environment variable in its caller?
Are comments included during the compilation stage and placed in the EXE file as well?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
Explain 'far' and 'near' pointers in c.
I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.
Why doesnt long int work?
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.
What is the importance of c in your views?