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
What is declaration and definition in c?
What is the use of bitwise operator?
What is the size of structure in c?
What is the difference between formatted&unformatted i/o functions?
c program for searching a student details among 10 student details
How to write c functions that modify head pointer of a linked list?
When should the const modifier be used?
What is zero based addressing?
What is the difference between scanf and fscanf?
Array is an lvalue or not?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
What are logical errors and how does it differ from syntax errors?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
what are the different storage classes in c?
Give me the code of in-order recursive and non-recursive.