Tell about strtok & strstr functions

Answers were Sorted based on User's Feedback



Tell about strtok & strstr functions..

Answer / swetcha


include <string.h>

char *strstr (char * s1 , const char * s2 );

In the above case
The strstr function locates the first occurrence in the
string pointed to by s1 of the sequence of characters
(excluding the terminating null character) in the string
pointed to by s2.

The strstr function returns a pointer to the located
string, or a null pointer if the string is not found. If s2
points to a string with zero length, the function returns
s1.
The strtok function
See the below case
#include <string.h>

char *strtok (char * s1 , const char * s2 );


A sequence of calls to the strtok function breaks the
string pointed to by s1 into a sequence of tokens, each of
which is delimited by a character from the string pointed
to by s2. The first call in the sequence has s1 as its
first argument, and is followed by calls with a null
pointer as their first argument. The separator string
pointed to by s2 may be different from call to call.


The strtok function returns a pointer to the first
character of a token, or a null pointer if there is no token

Is This Answer Correct ?    12 Yes 0 No

Tell about strtok & strstr functions..

Answer / shruti

The above answer is perfect...

Kudos..
well done..

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C Interview Questions

What is a macro?

0 Answers  


What is file in c preprocessor?

0 Answers  


What is the difference between char a[] = "string"; and char *p = "string"; ?

14 Answers   Adobe, Honeywell, TCS,


Explain the difference between exit() and _exit() function?

0 Answers  


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

0 Answers   InterGraph,






What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

0 Answers  


How many identifiers are there in c?

0 Answers  


Is null always equal to 0(zero)?

0 Answers  


What does c mean before a date?

0 Answers  


What is the difference between %d and %i?

0 Answers  


If null and 0 are equivalent as null pointer constants, which should I use?

0 Answers  


main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); } what is the output?

7 Answers   AMCAT, HCL, Ramco, Zycus Infotech,


Categories