C/C++ - "gx4_string" reference guide

<< BACK TO MENU

 

  SHORT DESCRIPTION: this header contains some functions and macros for working with strings; some of them are the rewritten versions of functionally identical functions found in <string.h>;
     
  DEFINITION/MACRO LIST:
    #define charupper(x) - converts single character 'x' to uppercase;
#define charlower(x) - converts single character 'x' to lowercase;
#define chr(n) - returns the character 'n' from the ASCII table;
#define chrcode(c) - returns the character code of 'c' from the ASCII table;

  FUNCTION LIST:
    slen (const char* );
slenull (const char* );
scopy (char* ,const char* );
slink (char* ,const char* );
scomp (const char* ,const char* );
snlink (char* ,const char* ,int );
sncomp (const char* ,const char* ,int );
sequal (const char* ,const char* );
siequal (const char* ,const char* );
string_lower (char* );
string_upper (char* );
charcount (const char* ,char );
string_reverse (char* );
string_set (char* ,char );

  long int slen (const char* pcString)
   

The slen() function is almost identical with "strlen()" function from <string.h> header. It has been rewritten so that it should have a name compliant with the next rewritten functions.

PARAMETERS:
pcString = the input string who's length is desired;

RETURN VALUES:
This function returns the length of the NULL terminated input string, without the NULL character.


  long int slenull(const char* pcString)
   

The slenull() function is identical with "slen()", but it calculates the length of a string terminated in two NULL characters, not just one.

PARAMETERS:
pcString = the input string who's length is desired;

RETURN VALUES:
This function returns the length of the double-NULL terminated input string, without the final NULL characters.

REMARKS:
This function's behaviour is useful when working in Win32 API with strings that define file types and extensions for OPENFILENAME.

EXAMPLE:
slenull("ana\0are\0mere\0\0") returns 12


  char* scopy(char* pcDest,const char* pcSrc)
   

The scopy() function is almost identical with "strcpy()" function from <string.h> header. It has been rewritten because "strcpy()" has the tendency to omit inserting the terminating NULL character.

PARAMETERS:
pcDest = the destination string;
pcSrc = the source string;

RETURN VALUES:
Returns the pcDest pointer.


  char* slink(char* pcDest,const char* pcSrc)
   

The slink() function is almostidentical with "strcat()" function from <string.h> header. It has been rewritten because "strcat()" has the tendency to omit inserting the terminating NULL character.

PARAMETERS:
pcDest = the destination string;
pcSrc = the source string;

RETURN VALUES:
Returns the pcDest pointer.


  int scomp(const char* s1,const char* s2)
   

The scomp() function is almost identical with "strcmp()" function from <string.h> header. It has been rewritten so that it should have a name compliant with the other rewritten functions.

PARAMETERS:
s1 = first string;
s2 = second string;

RETURN VALUES:
This function returns -2 if either pointers are NULL, 0 if the strings are identical, -1 if s1 is less than s2 or 1 if s1 is greater than s2.


  char* snlink(char* pcDest,const char* pcSrc,int n)
   

The snlink() function is almost identical with "strncat()" function from <string.h> header. It has been rewritten because "strncat()" has the tendency to omit inserting the terminating NULL character.

PARAMETERS:
pcDest = the destination string;
pcSrc = the source string;
n = bytes to copy;

RETURN VALUES:
Returns the pcDest pointer.


  int sncomp(const char* s1,const char* s2,int n)
   

The sncomp() function is almost identical with "strncmp()" function from <string.h> header. It has been rewritten so that it should have a name compliant with the other rewritten functions.

PARAMETERS:
s1 = the first string;
s2 = the second string;
n = bytes to compare;

RETURN VALUES:
This function returns -2 if either pointers are NULL, 0 if the strings are identical, -1 if s1 is less than s2 or 1 if s1 is greater than s2.


  int sequal(const char* pcStr1,const char* pcStr2)
   

This function compares the two strings and returns whether or not they are identical.

PARAMETERS:
pcStr1 = the first string;
pcStr2 = the second string;

RETURN VALUES:
This function returns 0 if either pointers are NULL or not identical and returns 1 if the two strings are identical.


  int siequal(const char* pcStr1,const char* pcStr2)
   

This is the case-insensitive version of "sequal()".


  char* string_lower(char* pcStr)
   

This function converts in-place the input string to lowercase.

PARAMETERS:
pcStr = the input string;

RETURN VALUES:
This function returns the pcStr pointer.


  char* string_upper(char* pcStr)
   

This function converts in-place the input string to uppercase.

PARAMETERS:
pcStr = the input string;

RETURN VALUES:
This function returns the pcStr pointer.


  long int charcount(const char* pcStr,char c)
   

This function counts the number of occurences of c character inside pcStr string.

PARAMETERS:
pcStr = the input string;
c = desired character to be counted;

RETURN VALUES:
This function returns the number of occurences of c character inside pcStr string.


  char* string_reverse(char* pcStr)
   

This function reverses the order of characters inside pcStr string, in-place.

PARAMETERS:
pcStr = the input string;

RETURN VALUES:
This function returns the input pointer.


  char* string_set(char* pcStr,char c)
   

This function fills all characters inside pcStr string with the value of c.

PARAMETERS:
pcStr = the input string;
c = desired character to be filled with;

RETURN VALUES:
This function returns the input pointer.