PS-Trainer C - Entwicklung
Bibliotheks-Funktionen: 1 String RW
Homepage von PS-Trainer - C-Entwicklung - Strings - an PS-Trainer
PS-Trainer PS-Trainer

Strings & characters Overview
_strnset, _wcsnset, _mbsnset Initialize characters of a string.
_strset, _wcsset, _mbsset Set characters of a string to a character.
_strupr, _wcsupr, _mbsupr Convert a string to uppercase.
_strlwr, _wcslwr, _mbslwr
Convert a string to lowercase.
_strrev, _wcsrev, _mbsrev Reverse characters of a string.


_strlwr, _wcslwr, _mbslwr
Convert a string to lowercase.
char *_strlwr( char *string );
wchar_t *_wcslwr( wchar_t *string );
unsigned char *_mbslwr( unsigned char *string );


Routine Required Header Compatibility
 _strlwr <string.h> Win 95, Win NT
 _wcslwr <string.h> or <wchar.h> Win 95, Win NT
 _mbslwr <mbstring.h> Win 95, Win NT

Remarks
The _strlwr function converts any uppercase letters in string to lowercase as determined by the LC_CTYPE category setting of the current locale. Other characters are not affected. For more information on LC_CTYPE, see setlocale.
The _wcslwr and _mbslwr functions are wide-character and multibyte-character versions of _strlwr. The argument and return value of _wcslwr are wide-character strings; those of _mbslwr are multibyte-character strings. These three functions behave identically otherwise.

Generic-Text Routine Mappings
TCHAR.H _UNICODE & _MBCS d _MBCS _UNICODE
Routine Not Defined Defined Defined
_tcslwr _strlwr _mbslwr _wcslwr

Subject: String Manipulation Routines, Locale Routines
Keywords: See also _strupr

Return Value
Each of these functions returns a pointer to the converted string. Because the modification is done in place, the pointer returned is the same as the pointer passed as the input argument. No return value is reserved to indicate an error.

Parameter
string Null-terminated string to convert to lowercase

Example
/* STRLWR.C: This program uses _strlwr and _strupr to create
* uppercase and lowercase copies of a mixed-case string.
*/

#include <string.h>
#include <stdio.h>

void main( void )
{
char string[100] = "The String to End All Strings!";
char *copy1, *copy2;
copy1 = _strlwr( _strdup( string ) );
copy2 = _strupr( _strdup( string ) );
printf( "Mixed: %s\n", string );
printf( "Lower: %s\n", copy1 );
printf( "Upper: %s\n", copy2 );
}


Output
Mixed: The String to End All Strings!
Lower: the string to end all strings!
Upper: THE STRING TO END ALL STRINGS!


_strupr, _wcsupr, _mbsupr
Convert a string to uppercase.
char *_strupr( char *string );
wchar_t *_wcsupr( wchar_t *string );
unsigned char *_mbsupr( unsigned char *string );


Routine Required Header Compatibility
 _strupr <string.h> Win 95, Win NT
 _wcsupr <string.h> or <wchar.h> Win 95, Win NT
 _mbsupr <mbstring.h> Win 95, Win NT

Remarks
The _strupr function converts, in place, each lowercase letter in string to uppercase. The conversion is determined by the LC_CTYPE category setting of the current locale. Other characters are not affected. For more information on LC_CTYPE, see setlocale.
_wcsupr and _mbsupr are wide-character and multibyte-character versions of _strupr. The argument and return value of _wcsupr are wide-character strings; those of _mbsupr are multibyte-character strings. These three functions behave identically otherwise.

Generic-Text Routine Mappings
TCHAR.H _UNICODE & _MBCS _MBCS _UNICODE
Routine Not Defined Defined Defined
_tcsupr _strupr _mbsupr _wcsupr

Subject: Locale Routines | String Manipulation Routines
Keywords: See Also _strlwr
Return Value
These functions return a pointer to the altered string. Because the modification is done in place, the pointer returned is the same as the pointer passed as the input argument. No return value is reserved to indicate an error.

Parameter
string String to capitalize

Example
/* STRLWR.C: This program uses _strlwr and _strupr to create
* uppercase and lowercase copies of a mixed-case string.
*/

#include <string.h>
#include <stdio.h>

void main( void )
{
char string[100] = "The String to End All Strings!";
char *copy1, *copy2;
copy1 = _strlwr( _strdup( string ) );
copy2 = _strupr( _strdup( string ) );
printf( "Mixed: %s\n", string );
printf( "Lower: %s\n", copy1 );
printf( "Upper: %s\n", copy2 );
}


Output
Mixed: The String to End All Strings!
Lower: the string to end all strings!
Upper: THE STRING TO END ALL STRINGS!


_strset, _wcsset, _mbsset
Set characters of a string to a character.
char *_strset( char *string, int c );
wchar_t *_wcsset( wchar_t *string, wchar_t c );
unsigned char *_mbsset( unsigned char *string, unsigned int c );


Routine Required Header Compatibility
 _strset <string.h> Win 95, Win NT
 _wcsset <string.h> or <wchar.h> Win 95, Win NT
 _mbsset <mbstring.h> Win 95, Win NT

Remarks
The _strset function sets all the characters of string to c (converted to char), except the terminating null character.
_wcsset and _mbsset are wide-character and multibyte-character versions of _strset. The data types of the arguments and return values vary accordingly. These three functions behave identically otherwise.

Generic-Text Routine Mappings
TCHAR.H _UNICODE & _MBCS _MBCS _UNICODE
Routine Not Defined Defined Defined
_tcsset _strset _mbsset _wcsset

Subject: String Manipulation Routines
Keywords: See Also _mbsnbset, memset, strcat, strcmp, strcpy, _strnset
Return Value
Each of these functions returns a pointer to the altered string. No return value is reserved to indicate an error.

Parameters
string Null-terminated string to be set
c Character setting

Example
/* STRSET.C */

#include <string.h>
#include <stdio.h>

void main( void )
{
char string[] = "Fill the string with something";
printf( "Before: %s\n", string );
_strset( string, '*' );
printf( "After: %s\n", string );
}


Output
Before: Fill the string with something
After: ******************************


_strrev, _wcsrev, _mbsrev
Reverse characters of a string.
char *_strrev( char *string );
wchar_t *_wcsrev( wchar_t *string );
unsigned char *_mbsrev( unsigned char *string );


Routine Required Header Compatibility
 _strrev <string.h> Win 95, Win NT
 _wcsrev <string.h> or <wchar.h> Win 95, Win NT
 _mbsrev <mbstring.h> Win 95, Win NT

Remarks
The _strrev function reverses the order of the characters in string. The terminating null character remains in place.
_wcsrev and _mbsrev are wide-character and multibyte-character versions of _strrev. The arguments and return value of _wcsrev are wide-character strings; those of _mbsrev are multibyte-character strings. For _mbsrev, the order of bytes in each multibyte character in string is not changed. These three functions behave identically otherwise.

Generic-Text Routine Mappings
TCHAR.H _UNICODE & _MBCS _MBCS _UNICODE
Routine Not Defined Defined Defined
_tcsrev _strrev _mbsrev _wcsrev

Subject: String Manipulation Routines
Keywords: See Also strcpy, _strset
Return Value
Each of these functions returns a pointer to the altered string. No return value is reserved to indicate an error.

Parameter
string Null-terminated string to reverse

Example
/* STRREV.C: This program checks an input string to
* see whether it is a palindrome: that is, whether
* it reads the same forward and backward.
*/

#include <string.h>
#include <stdio.h>

void main( void )
{
char string[100];
int result;

printf( "Input a string and I will tell you if it is a palindrome:\n" );
gets( string );

/* Reverse string and compare (ignore case): */
result = _stricmp( string, _strrev( _strdup( string ) ) );
if( result == 0 )
printf( "The string \"%s\" is a palindrome\n\n", string );
else
printf( "The string \"%s\" is not a palindrome\n\n", string );
}


Output
Input a string and I will tell you if it is a palindrome:
Able was I ere I saw Elba
The string "Able was I ere I saw Elba" is a palindrome


_strnset, _wcsnset, _mbsnset
Initialize characters of a string to a given format.
char *_strnset( char *string, int c, size_t count );
wchar_t *_wcsnset( wchar_t *string, wchar_t c, size_t count );
unsigned char *_mbsnset( unsigned char *string, unsigned int c, size_t count );


Routine Required Header Compatibility
 _strnset <string.h> Win 95, Win NT
 _wcsnset <string.h> or <wchar.h> Win 95, Win NT
 _mbsnset <mbstring.h> Win 95, Win NT

Remarks
The _strnset function sets, at most, the first count characters of string to c (converted to char). If count is greater than the length of string, the length of string is used instead of count.
_wcsnset and _mbsnset are wide-character and multibyte-character versions of _strnset. The string arguments and return value of _wcsnset are wide-character strings; those of _mbsnset are multibyte-character strings. These three functions behave identically otherwise.

Generic-Text Routine Mappings
TCHAR.H _UNICODE & _MBCS _MBCS _UNICODE
Routine Not Defined Defined Defined
_tcsnset _strnset _mbsnset _wcsnset

Subject: String Manipulation Routines
Keywords: See Also strcat, strcmp, strcpy, _strset
Return Value
Each of these functions returns a pointer to the altered string.

Parameters
string String to be altered
c Character setting
count Number of characters to be set

Example
/* STRNSET.C */

#include <string.h>
#include <stdio.h>

void main( void )
{
char string[15] = "This is a test";
/* Set not more than 4 characters of string to be *'s */
printf( "Before: %s\n", string );
_strnset( string, '*', 4 );
printf( "After: %s\n", string );
}


Output
Before: This is a test
After: **** is a test


Homepage von PS-Trainer - C-Entwicklung - Strings - an PS-Trainer

Aktuelle Daten dieser Seite Letzte Änderung:
  Geocities

 

 

 

Hosted by www.Geocities.ws

1