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

#include<stdio.h> int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

0 Answers  


struct node {struct node*temp,*new} prinf("%d",sizeof(struct node));

2 Answers  


What does & mean in scanf?

0 Answers  


a C prog to swap 2 no.s without using variables just an array?

5 Answers   TCS,


1,4,8,13,21,30,36,45,54,63,73,?,?.

10 Answers   AMB, Franklin Templeton,






1. What will be the output of the following programs. a) #include <stdio.h> Main() { Int x=4; While(x==1) { X=x-1; Printf(“%d”,x); --x; } }

7 Answers   CSC,


Do you know what is the purpose of 'extern' keyword in a function declaration?

0 Answers  


what is function pointer?

2 Answers   Wipro,


write a program to sum of its digit with using control structure or with out using loop. for ex: let the number is 25634 then answer will be=2+5+6+3+4=20

4 Answers  


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

0 Answers  


What are the preprocessor categories?

0 Answers  


Explain what is the difference between a free-standing and a hosted environment?

0 Answers  


Categories