Which of the following function is used to find the first occurrence of a given string in another string?
A.strchr()
B.strrchr()
C.strstr()
D.strnset()
Answers
Answered by
3
Option c
The function strstr() Finds the first occurrence of a substring in another string
Declaration: char *strstr(const char *s1, const char *s2);
Return Value:
On success, strstr returns a pointer to the element in s1 where s2 begins (points to s2 in s1).
On error (if s2 does not occur in s1), strstr returns null.
The function strstr() Finds the first occurrence of a substring in another string
Declaration: char *strstr(const char *s1, const char *s2);
Return Value:
On success, strstr returns a pointer to the element in s1 where s2 begins (points to s2 in s1).
On error (if s2 does not occur in s1), strstr returns null.
Answered by
0
C. strstr() is the proper answer.
Explanation for Correct answer:
- The characteristic strstr returns the primary occurrence of a string in any other string. This way that strstr may be used to discover whether or not a string carries any other string.
Explanation for wrong answers :
A. strchr():
- The strchr() characteristic returns a pointer to the primary incidence of c this is transformed to an individual withinside the string. The characteristic returns NULL if the desired individual isn't always found.
B. strrchr():
- The strrchr() characteristic reveals the final incidence of c in string. The finishing null individual is taken into consideration as a part of the string. Return Value.
D. strnset():
- The strnset() feature is a built-in characteristic in C and its sets the primary n characters of a string to a given individual. If n is more than the duration of the string, the duration of a string is utilized in the location of n.
#SPJ2
Similar questions
Math,
7 months ago
English,
7 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago