Tell about strtok & strstr functions

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a program to generate address labels using structures?

4008


What is nested structure?

576


Explain what is wrong in this statement?

635


What is the difference between pure virtual function and virtual function?

653


write a c program to calculate sum of digits till it reduces to a single digit using recursion

2722






What is indirection in c?

630


What are the 4 types of functions?

574


What is strcmp in c?

601


What standard functions are available to manipulate strings?

565


Why do we need a structure?

590


How can I rethow can I return a sequence of random numbers which dont repeat at all?

707


Explain the use of 'auto' keyword in c programming?

684


What are the functions to open and close file in c language?

730


What is a char in c?

557


How is = symbol different from == symbol in c programming?

615