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 are the benefits of c language?

0 Answers  


fn f(x) { if(x<=0) return; else f(x-1)+x; }

5 Answers   HCL,


What is the use of a static variable in c?

0 Answers  


What does %p mean?

0 Answers  


how to compare two strings without using strcmp() function??

1 Answers  






5. distance conversion: Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer

4 Answers  


Why double pointer is used in c?

0 Answers  


a simple c program using 'for' loop to display the output 5 4 3 2 1

2 Answers   Google,


Why preprocessor should come before source code?

2 Answers  


cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration

0 Answers  


wap in c to accept a number display the total count of digit

4 Answers  


please send me papers for Dy. manager IT , PNB. it would be a great help for me.

0 Answers  


Categories