How to determine different positions of substrings within a string in C?

There are numerous functions available in C to achieve the purpose of finding different positions of a substring with a string.



strstr():



To obtain the first occurrence of substring in a string the function used is strstr().


The syntax for this function is



char *strstr( const char *str1, const char *str2 );



The header file that must be included while using this function strstr() is <string.h>


In the above the function strstr() returns a pointer to the first occurrence of str2 in str1. If no match is found then NULL is returned.



strrstr():



This function is used to obtain the last occurrence of substring in a string.


The syntax for this function is



strrstr(const char *s, const char *subs );



The header file that must be included while using the function strrstr() is <sdgstd.h>


This returns a pointer which points to the last occurrence of a substring within another string. If the substring is not found, this will be the NULL pointer.

Questions by GeekAdmin   answers by GeekAdmin

Showing Answers 1 - 1 of 1 Answers

sathish

  • Oct 12th, 2006
 

while traversing along a string find whether the current character is a blank space or not.if so count the position

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions