Watcom C Library : strrchr, _fstrrchr, strrev, _fstrrev, strset, _fstrset, strspn, _fstrspn, strstr, _fstrstr, strtod
Watcom C Reference/S 2021. 11. 18. 17:20
Watcom C Library Reference : strrchr, _fstrrchr, strrev, _fstrrev, strset, _fstrset, strspn, _fstrspn, strstr, _fstrstr, strtod
strrchr, _fstrrchr
Synopsis : #include <string.h>
char *strrchr( const char *s, int c );
char __far *_fstrrchr( const char __far *s, int c );
Description : The strrchr and _fstrrchr functions locate the last occurrence of c (converted to a char) in the string pointed to by s. The terminating null character is considered to be part of the string.
The _fstrrchr function is a data model independent form of the strrchr function. It accepts far pointer arguments and returns a far pointer. It is most useful in mixed memory model applications.
Returns : The strrchr and _fstrrchr functions return a pointer to the located character, or a NULL pointer if the character does not occur in the string.
See Also : strchr, strpbrk
Example :
#include <stdio.h>
#include <string.h>
void main( )
{
printf( "%s\n", strrchr( "abcdeabcde", 'a' ) );
if( strrchr( "abcdeabcde", 'x') == NULL )
printf( "NULL \n" );
}
produces the following :
abcde
NULL
Classification : strrchr is ANSI, _fstrrchr is not ANSI
Systems : strrchr - All
_fstrrchr - All
strrev, _fstrrev
Synopsis : #include <string.h>
char *strrev( char *s1 );
char __far *_fstrrev( charfar *s1 );
Description : The strrev and _fstrrev functions replace the string s1 with a string whose characters are in the reverse order.
The _fstrrev function is a data model independent form of the strrev function. It accepts far pointer arguments and returns a far pointer. It is most useful in mixed memory model applications.
Returns : The address of the original string s1 is returned.
Example :
#include <stdio.h>
#include <string.h>
char source[] = { "A sample STRING" };
void main( )
{
printf( "%s\n", source );
printf( "%s\n", strrev( source ) );
printf( "%s\n", strrev( source ) );
}
produces the following :
A sample STRING
GNIRTS elpmas A
A sample STRING
Classification : WATCOM
Systems : strrev - All
_fstrrev - All
strset, _fstrset
Synopsis : #include <string.h>
char *strset( char *s1, int fill );
char __far *_fstrset( char __far *s1, int fill );
Description : The strset and _fstrset functions fill the string pointed to by s1 with the character fill. The terminating null character in the original string remains unchanged.
The _fstrset function is a data model independent form of the strset function. It accepts far pointer arguments and returns a far pointer. It is most useful in mixed memory model applications.
Returns : The address of the original string s1 is returned.
See Also : strnset
Example :
#include <stdio.h>
#include <string.h>
char source[] = { "A sample STRING" };
void main( )
{
printf( "%s\n", source );
printf( "%s\n", strset( source, '=' ) );
printf( "%s\n", strset( source, '*' ) );
}
produces the following :
A sample STRING
===============
***************
Classification : WATCOM
Systems : strset - All
_fstrset - All
strspn, _fstrspn
Synopsis : #include <string.h>
size_t strspn( const char *str, const char *charset );
size_t _fstrspn( const char __far *str, const char __far *charset );
Description : The strspn and _fstrspn functions compute the length of the initial segment of the string pointed to by str which consists of characters from the string pointed to by charset. The terminating null character is not considered to be part of charset.
The _fstrspn function is a data model independent form of the strspn function that accepts far pointer arguments. It is most useful in mixed memory model applications.
Returns : The strspn and _fstrspn functions return the length of the segment.
See Also : strcspn
Example :
#include <stdio.h>
#include <string.h>
void main( )
{
printf( "%d\n", strspn( "out to lunch", "aeiou" ) );
printf( "%d\n", strspn( "out to lunch", "xyz" ) );
}
produces the following :
2
0
Classification : strspn is ANSI, _fstrspn is not ANSI
Systems : strspn - All
_fstrspn - All
strstr, _fstrstr
Synopsis : #include <string.h>
char *strstr( const char *str, const char *substr );
char __far *_fstrstr( const char __far *str, const char __far *substr );
Description : The strstr and _fstrstr functions locate the first occurrence in the string pointed to by str of the sequence of characters (excluding the terminating null character) in the string pointed to by substr.
The _fstrstr function is a data model independent form of the strstr function. It accepts far pointer arguments and returns a far pointer. It is most useful in mixed memory model applications.
Returns : The strstr and _fstrstr functions return a pointer to the located string, or NULL if the string is not found.
See Also : strcspn
Example :
#include <stdio.h>
#include <string.h>
void main( )
{
printf( "%s\n", strstr( "This is an example", "is" ) );
}
produces the following :
is is an example
Classification : strstr is ANSI, _fstrstr is not ANSI
Systems : strstr - All
_fstrstr - All
strtod
Synopsis : #include <stdlib.h>
double strtod( const char *ptr, char **endptr );
Description : The strtod function converts the string pointed to by ptr to double representation. The function recognizes a string containing :
• optional white space. | |
• an optional plus or minus sign. | |
• a sequence of digits containing an optional decimal point. | |
• an optional 'e' or 'E' followed by an optionally signed sequence of digits. |
The conversion ends at the first unrecognized character. A pointer to that character will be stored in the object to which endptr points if endptr is not NULL.
Returns : The strtod function returns the converted value. If the correct value would cause overflow, plus or minus HUGE_VAL is returned according to the sign, and errno is set to ERANGE. If the correct value would cause underflow, then zero is returned, and errno is set to ERANGE. Zero is returned when the input string cannot be converted. When an error has occurred, errno contains a value indicating the type of error that has been detected.
See Also : atof
Example :
#include <stdio.h>
#include <stdlib.h>
void main( )
{
double pi;
pi = strtod( "3.141592653589793", NULL );
printf( "pi=%17.15f\n", pi );
}
Classification : ANSI
Systems : All
This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).
WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)