strtok()
Syntax:
#include
char *strtok( char *str1, const char *str2 );
Description:
The strtok() function returns a pointer to the next "token" in str1, where str2 contains the delimiters that determine the token. strtok() returns NULL if no token is found. In order to convert a string to tokens, the first call to strtok() should have str1 point to the string to be tokenized. All calls after this should have str1 be NULL.
Example:
char str[] = "now # is the time for all # good men to come to the # aid of their country";
char delims[] = "#";
char *result = NULL;
result = strtok( str, delims );
while( result != NULL ) {
printf( "result is \"%s\"\n", result );
result = strtok( NULL, delims );
}
OUTPUT:
result is "now "
result is " is the time for all "
result is " good men to come to the "
result is " aid of their country"
2:
strchr()
Syntax:
#include
Description:
The function strchr() returns a pointer to the first occurence of ch in str, or NULL if ch is not found.
3:
Syntax:
#include
char *strrchr( const char *str, int ch );
Description:
The function strrchr() returns a pointer to the last occurrence of ch in str, or NULL if no match is found.
4:Syntax:
#include
char *strstr( const char *str1, const char *str2 );
Description:
The function strstr() returns a pointer to the first occurrence of str2 in str1, or NULL if no match is found.
5:
Syntax:
#include
char *strpbrk( const char *str1, const char *str2 );
Description:
The function strpbrk() returns a pointer to the first ocurrence in str1 of any character in str2, or NULL if none are present.
6:
No comments:
Post a Comment